void CexceptionDlg::OnBnClickedOk()
{
CString str="hello world";
TRY {
CFile file("c:\\hello.txt",CFile::modeCreate| CFile::modeWrite);
file.Write(str,str.GetLength());
file.Close();
} CATCH(CFileException,e)
{
switch(e->m_cause)
{
case CFileException::accessDenied :
AfxMessageBox("file accessDenied");
  break;
case CFileException::fileNotFound: 
AfxMessageBox("file not found");
      break;
      }
} OnOK();
}
出错提示:
C:\Program Files\Microsoft Visual Studio\MyProjects\aaa\aaaDlg.cpp(195) : fatal error C1004: unexpected end of file found
百思不得其解

解决方案 »

  1.   

    CATCH(CFileException,e)
    {
    switch(e->m_cause)
    {
    case CFileException::accessDenied :
    AfxMessageBox("file accessDenied");
      break;
    case CFileException::fileNotFound: 
    AfxMessageBox("file not found");
          break;
          }
    加一句试市  file.Close();
    }
      

  2.   

    最后加上
    END_CATCHCATCH(CFileException,e)
    {
    switch(e->m_cause)
    {
    case CFileException::accessDenied :
    AfxMessageBox("file accessDenied");
      break;
    case CFileException::fileNotFound: 
    AfxMessageBox("file not found");
          break;
          }
    }END_CATCH