Contains values defined by a CFileException enumerated type.


int m_cause;


This data member is a public variable of type int. The enumerators and their meanings are as follows:

  • CFileException::none   0: No error occurred.

  • CFileException::genericException   1: An unspecified error occurred.

  • CFileException::fileNotFound   2: The file could not be located.

  • CFileException::badPath   3: All or part of the path is invalid.

  • CFileException::tooManyOpenFiles   4: The permitted number of open files was exceeded.

  • CFileException::accessDenied   5: The file could not be accessed.

  • CFileException::invalidFile   6: There was an attempt to use an invalid file handle.

  • CFileException::removeCurrentDir   7: The current working directory cannot be removed.

  • CFileException::directoryFull   8: There are no more directory entries.

  • CFileException::badSeek   9: There was an error trying to set the file pointer.

  • CFileException::hardIO   10: There was a hardware error.

  • CFileException::sharingViolation   11: SHARE.EXE was not loaded, or a shared region was locked.

  • CFileException::lockViolation   12: There was an attempt to lock a region that was already locked.

  • CFileException::diskFull   14: The disk is full.

  • CFileException::endOfFile   15: The end of file was reached.


    These CFileException cause enumerators are distinct from the CArchiveException cause enumerators.


    CArchiveException::generic is deprecated. Use genericException instead. If generic is used in an application and built with /clr, the resulting syntax errors are not easy to decipher.


   CFile f(_T("M_Cause_File.dat"), CFile::modeWrite);
catch(CFileException* e)
   if( e->m_cause == CFileException::fileNotFound)
      TRACE(_T("ERROR: File not found\n"));


Header: afx.h

See Also

CFileException Class
Hierarchy Chart