BOOL GetStatus(CFileStatus& rStatus) const;
CFileStatus是一个结构体,此结构体存储了文件的状态信息。下面我们来看看其结构体成员:
CTime m_ctime The date and time the file was created.
表示文件的创建时间
CTime m_mtime The date and time the file was last modified.
表示文件的修改时间
CTime m_atime The date and time the file was last accessed for reading.
表示文件的最后访问时间
ULONGLONG m_size The logical size of the file in bytes, as reported by the DIR command.
表示文件的逻辑大小
BYTE m_attribute The attribute byte of the file.
表示文件的系统属性
char m_szFullName[_MAX_PATH] The absolute filename in the Windows character set.
表示文件的绝对路径
看看代码示例:
CFile cfile;
cfile.Open(_T("SetLength_File.dat"), CFile::modeCreate |
CFile::modeReadWrite);
ULONGLONG dwNewLength = 10000;
cfile.SetLength(dwNewLength);
CFileStatus status;
if(cfile.GetStatus(status)) // virtual member function
{
TRACE(_T("File size = %u\n"), status.m_size);
}
TCHAR* pszFileName = _T("SetLength_File.dat");
if(CFile::GetStatus(pszFileName, status)) // static function
{
TRACE(_T("Full file name = %s\n"), status.m_szFullName);
}