当前位置:C++技术网 > 资讯 > CFileStatus结构体实现文件属性详细信息查找设置

CFileStatus结构体实现文件属性详细信息查找设置

更新时间:2016-02-03 20:52:54浏览次数:1+次

用户在进行程序开发的时候,有时需要获得文件的属性信息。cFile类定义了一个获取与设置文件信息的方法:
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);
}