hi folks,
Right, I've been stuck on this for a couple of days now. I'm trying to load a file by dragging and dropping a file onto the .exe, extract the data & trim it, then write to another file.
The original problem is here
http://www.cplusplus.com/forum/beginner/59633/
I've since reduced the code to test the read and write streams...
I've run the following code twice, once with running the .exe on it's own and once by dragging and dropping a file. Results are below the code.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
#include <iostream>
#include <fstream>
using namespace std;
int main(int argc, char *argv[])
{
ifstream InputFile;
ifstream InputFile2;
ofstream OutputFile;
InputFile.open (argv[1]);
cout<<"Drag'n'Drop is "<<InputFile.is_open()<<"\n";
InputFile2.open ("DAP.csv");
cout<<"DAP.csv is "<<InputFile2.is_open()<<"\n";
OutputFile.open("FileWrite.txt");
cout<<"Output file is "<<OutputFile.is_open()<<"\n";
OutputFile<<"writting data to file \n";
InputFile.close();
InputFile2.close();
OutputFile.close();
system("PAUSE");
return EXIT_SUCCESS;
}
|
Open as stand alone .exe
RESULTS from cmdwindow
Drag'n'Drop is 0
DAP.csv is 1
Output file is 1
Press any key to continue . . .
output
IS created and written to
------------------------------------------------------------------------
Running .exe from Drag n Drop of a .txt file
RESULTS from cmdwindow
Drag'n'Drop is 1
DAP.csv is 0
Output file is 1
Press any key to continue . . .
output
IS NOT created and written to even though it's status is 1
------------------------------------------------------------------------
Can anyone shed some light or direct me to some reading material on the subject/problem?
EDIT: All the input files are in the same directory as the .exe