01-30-2009 12:08 PM
Hello
I am trying to set up an automatic new log file opening sequence in my program using DateStr and TimeStr as follows:
char gLogPath[MAX_PATHNAME_LEN];
int handleLogFile;
Fmt(gLogPath,"C:\\RunData\\MTB_RUN%s%s.txt",DateStr(),TimeStr());
RemoveFileIfExists (gLogPath);
handleLogFile = OpenFile (gLogPath, VAL_WRITE_ONLY, VAL_TRUNCATE, VAL_ASCII); // Create it
The program errors out saying that there is a "bad file handle". If I had only a single '\' in my file path then I receive a warning saying that there are bad characters \R and \M in my file path, so I converted these two to '\\'. Can someone please suggest where I am going wrong here?
Thanks
Ajit
01-30-2009 02:56 PM
The cause of the error can be in the result of DateStr () and TimStr (), depending on date and time separators as defind in control panel: as an example, my locale uses slashes as date separators and colons as time separators, both of them illegal inside a filename...
If this is your case, you could for example design a function that scans the string and substitutes those characters with hyphens or underscores.