2.2.5.1.8 file::IsOpen

Description

Check file object is open or not, when use a method of File object which is not open will lead a runtime error. Use this function before you call the method of File object.

Syntax

BOOL IsOpen( )

Parameters

Return

True of success, else false

Examples

EX1

//This function opens/creates the file c:\test.txt.
void file_IsOpen_ex1()   
{
    file ff;
    BOOL bOK;

    string strFile = "C:\\test.txt";  
           
    bOK = ff.Open(strFile, file::modeCreate | file::modeWrite);  //create a new write only file and open it
    if(!bOK)
        out_str("failed to open the file");                       
    else
    {
        if( ff.IsOpen() )
        {
            printf("The ff file is open");  //The string should be output
            ff.Close();  //Close the ff file
        }
    }
}

Remark

See Also

Header to Include

origin.h