2.2.5.1.5 file::GetLastError

Description

Get the value of the last error that occured.

Syntax

UINT GetLastError( )

Parameters

Return

Return the value of the last error that occured.

FileError::none = No error occurred.

FileError::generic = An unspecified error occurred.

FileError::fileNotFound = The file could not be located.

FileError::badPath = All or part of the path is invalid.

FileError::tooManyOpenFiles = The permitted number of open files was exceeded.

FileError::accessDenied = The file could not be accessed.

FileError::invalidFile = There was an attempt to use an invalid file handle.

FileError::removeCurrentDir = The current working directory cannot be removed.

FileError::directoryFull = There are no more directory entries.

FileError::badSeek = There was an error trying to set the file pointer.

FileError::hardIO = There was a hardware error.

FileError::sharingViolation = SHARE.EXE was not loaded, or a shared region was locked.

FileError::lockViolation = There was an attempt to lock a region that was already locked.

FileError::diskFull = The disk is full.

FileError::endOfFile = The end of file was reached.

Examples

EX1

//This function open the file c:\test.txt and get the value of the last error 
//if open file fails.
void file_GetLastError_ex1()  
{
    file ff;
    string strFile = "C:\\test.txt";  
    UINT nFileErr;
    BOOL bOK;
 
    bOK = ff.Open(strFile, file::modeWrite); //open the file, but the file does not exist. 
    if (!bOK)
    {
    	nFileErr = ff.GetLastError();
        printf("failed to open the file: %d", nFileErr);  //the nFileErr should not be output     
    }
    else
        ff.Close();               
}

Remark

See Also

Header to Include

origin.h