CFileStatus使用
来源:互联网 发布:三国讲了什么知乎 编辑:程序博客网 时间:2024/06/07 11:47
做一个小项目时要求输出文件的名称、属性、时间、大小等信息,然后在论坛里看到大神推荐CFileStatus可以获取文件信息,在这里总结记录一下,可能不全,欢迎指出错误以及评论补充。
首先FileStatus是一个结构体,此结构体存储了文件的状态信息。
下面是其结构体成员,来源于CSDN:
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.
表示文件的绝对路径
示例如下:
CListCtrl m_list;
m_list.InsertColumn( 0, "文件大小", LVCFMT_CENTER, rect.right /4 );
m_list.InsertColumn( 1, "文件类型" , LVCFMT_CENTER, rect.right /4);
m_list.InsertColumn( 2, "修改日期" , LVCFMT_CENTER, rect.right /4);
CFileStatus status;
CFile::GetStatus(tempPath + finder.GetFileName(), status);
CString strSize;
strSize.Format(_T("%d KB"),status.m_size/1024);
m_list.SetItemText(i,0,strSize);
CString strModifyTime = status.m_mtime.Format("%Y-%m-%d %H:%M:%S");
m_list.SetItemText(i,1,strModifyTime);
CString strCreateTime = status.m_ctime.Format("%Y-%m-%d %H:%M:%S");
m_list.SetItemText(i,2,strCreateTime);
上面的示例中,前四行是调用CListCtrl创建一个标题行,效果如下:
然后在①处,建立一个从CFileStatus对象并根据路径名(tempPath)与文件名(finder.GetFileName())将对应的文件信息返回给status,在②③④处再将其在对应位置显示出来。
- CFileStatus使用
- CFileStatus 使用详解
- 使用
- 使用
- 使用
- 使用
- 使用
- 使用
- 使用++,--
- 使用$@ $!
- 使用
- SoftICE使用(指令使用)
- 使用GraphEdit使用
- 使用HtmlParser使用心得
- 时钟使用使用
- Ubuntu 使用Git 使用
- Ubuntu 使用Git 使用
- GUID使用的使用
- C/C++作业2
- Istio及Bookinfo示例程序安装试用笔记
- 一个保存bmp的c代码
- 唯快不破:redis源码剖析05-ziplist字符串压缩链表
- 02-Html学习
- CFileStatus使用
- 0.设计模式介绍
- Ubuntu安装和配置JDK
- 编写输出1~100之间的素数,要求每行显示5个数
- ubuntu
- spring jdbc 使用多个数据源
- zipimport.ZipimportError的解决方法
- 字符串循环左移
- 【财富空间】京东首席战略官廖建文:有能力定义未来,才能超越竞争