09-19-2016 07:44 AM
32 should indicate a conflict with another process owning the file. See here.
Decoding SDK errors can be done by means of FormatMessage () function. In your case you could do something like this:
int error; char buf[512]; if ((DeleteFile ("temp-txt")) == 0) { sprintf (buf, "%s %s %s:", DateStr (), TimeStr (), __FUNCTION__); // GetLastError + FormatMessage // DWORD WINAPI GetLastError(void); // DWORD WINAPI FormatMessage ( // __in DWORD dwFlags, // __in LPCVOID lpSource, // __in DWORD dwMessageId, // __in DWORD dwLanguageId, // __out LPTSTR lpBuffer, // __in DWORD nSize, // __in va_list* Arguments //); error = GetLastError (); FormatMessage ( FORMAT_MESSAGE_FROM_SYSTEM, // __in DWORD dwFlags, NULL, // __in LPCVOID lpSource, error, // __in DWORD dwMessageId, 0, // __in DWORD dwLanguageId, buf + strlen (buf), // __out LPTSTR lpBuffer, 511 - strlen (buf), // __in DWORD nSize, NULL // __in va_list* Arguments ); sprintf (buf, "%s (%d)", buf, error); // Show error message MessagePopup ("Error!", buf); }
09-19-2016 09:28 AM
I tried copying the code given by you and executed. It did not go into the function as Deletefile() is not returning zero. I had to remove the if() condition to make FormatMessage() work.
However the problem is resolved now. The file was not closing properly. So I had to use one more fclose(). And to close the file I used remove(). And it is working fine now.
Thanks for the replies. 🙂
09-23-2016 02:13 PM
As far as the conflict between the CVI and SDK versions of DeleteFile is concerned, you can always work around these collisions by setting the SDK_CONFLICT_PRIORITY macro.