Debug Assertion failed

Hello,
I'm new in C++ programming (using VS2005). I'm trying to use save file dialog. Here is my code:

void CsampleDlg::StopRfWrite()
{

if (pFile != NULL)
fclose(pFile);

pFile = NULL;

char dir[512];
GetCurrentDirectoryA(512, dir);
CString connected=CString(dir) + _T("\\");
CString conn = connected + fn;

TCHAR szFilters[]= _T("RF data file (*.bin)|*.bin||");



// Create an Open dialog; the default file name extension is ".my".
CFileDialog fileDlg(FALSE, _T("bin"), fn,
OFN_FILEMUSTEXIST | OFN_HIDEREADONLY, szFilters);


// Display the file dialog. When user clicks OK, fileDlg.DoModal()
// returns IDOK.


if(fileDlg.DoModal() == IDOK)
{

CString pathName = fileDlg.GetPathName();
CString fileName = fileDlg.GetFileTitle();

SetWindowText(fileName);

MoveFile(conn,pathName);
}
else
{
DeleteFile(conn);
}

}

and receive
Debug Assertion failed error; (Line 384 in wincore.cpp) it is invoked by fileDlg.DoModal() call. It is random, sometimes program run fine.

Call Stack indicates the following row: ASSERT(pWnd != NULL);

Please help





Somewhere in the call stack is your code. Find the part of your code that's going wrong.
Topic archived. No new replies allowed.