OnSaveDocument中保存文件的奇怪问题?
函数代码如下:
BOOL CSdiDoc::OnSaveDocument(LPCTSTR lpszPathName)
{
// TODO: Add your specialized code here and/or call the base class
CFile file;
if(file.Open(lpszPathName, CFile::modeCreate|CFile::modeWrite) == FALSE)
return FALSE;
file.Write("Test", 5);
file.Close();
return TRUE; //注释这一行,写文件不成功
//return CDocument::OnSaveDocument(lpszPathName);
}
上面的代码能正确写入文件,如果返回的是最后一个行
return CDocument::OnSaveDocument(lpszPathName);
则只能创建文件,数据不能写入文件。
这是什么原因?