Exception while opening file

Posted by viswanathan on Stack Overflow See other posts from Stack Overflow or by viswanathan
Published on 2010-03-24T09:24:07Z Indexed on 2010/03/24 9:33 UTC
Read the original article Hit count: 373

Filed under:
|
|
|

Hi

I have a VC++ application and in my application i have some basic file operations.

Below is the defaulting code

CStdioFile cFile;
CFileException e;
CString sReport;
CString sHtmlfile = "testreport.html"
OutputDebugString((sHtmlfile));
if (!cFile.Open(sHtmlfile,CFile::modeCreate | CFile::modeWrite, &e ))
{
}

The problem is my application executes this piece of code every few minutes. and it works fine.

After several runs of the code the cFile.Open() function fails. I tried to get the error message

TCHAR szError[1024];
e.GetErrorMessage(szError,1024);
OutputDebugString((szError));

The irony is the szError error message is "No error occured".

This again works once i restart my application. Any idea why this occurs.

Thanks in advance.

© Stack Overflow or respective owner

Related posts about exception-handling

Related posts about files