我用CFile和CStdioFile类操作文件,请问,如何判定文件已经关闭?多谢了

解决方案 »

  1.   

    CFile::hFileNullif (myFile.m_hFile != CFile::hFileNull)
       //perform operations on the file
    else
       //indicate the presence of an invalid handle
      

  2.   

    up
    CFile::hFileNullSee Also
    CFile Overview | Class Members | Hierarchy ChartDetermines the presence of a valid file handle for the CFile object.
    static AFX_DATA const HANDLE hFileNull;
    Res
    This constant is used to determine if the CFile object has a valid file handle.
    The following example demonstrates this operation:
    if (myFile.m_hFile != CFile::hFileNull)
       //perform operations on the file
    else
       //indicate the presence of an invalid handle