G
gsegria
Guest
I created a MFC MDI applicatoin template using CRichEditView to open a text file using Doc::OnSaveDocument(LPCTSTR lpszPathName) with CRichEditDoc .
Code will failed on ReportSaveLoadException.
When i press Save or SaveAs , there was a error message as below.
==================================================
Here is my sample code
==================================================
BOOL CEditDoc::OnSaveDocument(LPCTSTR lpszPathName)
{
CFileException fe;
CFile* pFile = NULL;
pFile = GetFile(lpszPathName, CFile::modeCreate | CFile::modeReadWrite | CFile::shareExclusive, &fe);
if (pFile == NULL)
{
ReportSaveLoadException(lpszPathName, &fe, TRUE, AFX_IDP_INVALID_FILENAME);
return FALSE;
}
CArchive saveArchive(pFile, CArchive::store | CArchive::bNoFlushOnDelete);
saveArchive.m_pDocument = this;
saveArchive.m_bForceFlat = FALSE;
TRY
{
CWaitCursor wait;
Serialize(saveArchive); // save me
saveArchive.Close();
ReleaseFile(pFile, FALSE);
}
CATCH_ALL(e)
{
ReleaseFile(pFile, TRUE);
TRY
{
ReportSaveLoadException(lpszPathName, e, TRUE, AFX_IDP_FAILED_TO_SAVE_DOC);
}
END_TRY
//DELETE_EXCEPTION(e)
return FALSE;
}
END_CATCH_ALL
SetModifiedFlag(FALSE);
return TRUE;
}
Continue reading...
Code will failed on ReportSaveLoadException.
When i press Save or SaveAs , there was a error message as below.
==================================================
Here is my sample code
==================================================
BOOL CEditDoc::OnSaveDocument(LPCTSTR lpszPathName)
{
CFileException fe;
CFile* pFile = NULL;
pFile = GetFile(lpszPathName, CFile::modeCreate | CFile::modeReadWrite | CFile::shareExclusive, &fe);
if (pFile == NULL)
{
ReportSaveLoadException(lpszPathName, &fe, TRUE, AFX_IDP_INVALID_FILENAME);
return FALSE;
}
CArchive saveArchive(pFile, CArchive::store | CArchive::bNoFlushOnDelete);
saveArchive.m_pDocument = this;
saveArchive.m_bForceFlat = FALSE;
TRY
{
CWaitCursor wait;
Serialize(saveArchive); // save me
saveArchive.Close();
ReleaseFile(pFile, FALSE);
}
CATCH_ALL(e)
{
ReleaseFile(pFile, TRUE);
TRY
{
ReportSaveLoadException(lpszPathName, e, TRUE, AFX_IDP_FAILED_TO_SAVE_DOC);
}
END_TRY
//DELETE_EXCEPTION(e)
return FALSE;
}
END_CATCH_ALL
SetModifiedFlag(FALSE);
return TRUE;
}
Continue reading...