The following code snippet behaves in Debug mode (VC++ 2005) differently than in Release:
HANDLE hFileRead;
hFileRead = CreateFile(pszListFile, // lpFileName,
GENERIC_READ, // dwDesiredAccess,
FILE_SHARE_READ, // dwShareMode,
NULL, // lpSecurityAttributes,
OPEN_EXISTING, // dwCreationDisposition,
FILE_ATTRIBUTE_NORMAL, // dwFlagsAndAttributes,
0); // hTemplateFile
In Release mode it works perfectly. In Debug mode, it it returns INVALID_HANDLE_VALUE in hFileRead. Further retrieving GetLastError() reveals system error 3:
ERROR_PATH_NOT_FOUND ("The system cannot find the path specified.")
This is weird. In Release mode it can find it but in Debug mode it cannot find it? How is this possible?
Any ideas?