I need to develop a piece of code in an old legacy Visual C++ 6.0 system. I am invoking a stand-alone executable via a system call. This exe is supposed to create a file if processing goes OK or not create one if it fails. The name of the file to create is passed to the exe as a command-line argument. When I invoke this exe from a console window, in a certain case it fails to process and does not create the output file. However, when I invoke the same exe through the system call form my VC++ system, it fails but also creates an empty file. I invoke it using
CreateProcess()
. I have two questions:
1. Why is it creating the empty file?
2. To check for success/failure I am currently doing this:
if( _access( strDestFile, 0 ) == -1 ) {
// file does not exist
}
I guess I need to also check if the file is non-empty. What's the easiest way of doing it in VC++ 6.0?
Thanks!