文件按创建时间排序

kyukin 2006-10-13 07:44:21
在某个文件夹下有若干文件,我要取得文件名,并且是按创建时间排序的,请问在C++里有什么比较好的做法,谢谢
...全文
494 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
飞哥 2006-10-15
  • 打赏
  • 举报
回复
使用windows nt 2000 native api,文档需要参考 DDK

ZwQueryInformationFile
----------------
ZwQueryInformationFile
ZwQueryInformationFile retrieves information about a file object.
NTSYSAPI
NTSTATUS
NTAPI
ZwQueryInformationFile(
IN HANDLE FileHandle,
OUT PIO_STATUS_BLOCK IoStatusBlock,
OUT PVOID FileInformation,
IN ULONG FileInformationLength,
IN FILE_INFORMATION_CLASS FileInformationClass
);
Parameters
FileHandle
A handle to a file object.The handle must grant FILE_READ_DATA or FILE_READ_EA
access for some information classes.
IoStatusBlock
Points to a variable that receives the final completion status and information about the
requested operation.
FileInformation
Points to a caller-allocated buffer or variable that receives the requested file
information.
FileInformationLength
The size in bytes of FileInformation, which the caller should set according to the
given FileInformationClass.
FileInformationClass
Specifies the type of file information to be queried.The permitted values are a subset
of the enumeration FILE_INFORMATION_CLASS, described in the following section.
Return Value
Returns STATUS_SUCCESS or an error status, such as STATUS_ACCESS_DENIED,
STATUS_INVALID_HANDLE, STATUS_INVALID_INFO_CLASS, or STATUS_INFO_LENGTH_MISMATCH.
1996 CH13 12/1/99 12:34 PM Page 316
Files: ZwSetInformationFile 317
Related Win32 Functions
GetFileInformationByHandle, GetFileSize, GetCompressedFileSize, GetFileTime.
Remarks
ZwQueryInformationFile is documented in the DDK.
taodm 2006-10-15
  • 打赏
  • 举报
回复
标准C++里,没有提供获得文件创建时间的方法。
要么,上boost::filesystem,要么去windows编程版问
westdot 2006-10-13
  • 打赏
  • 举报
回复
定义一个WIN32_FIND_DATA类型的数组,将获得的每个文件的信息都放入这个数组中,再按时间对数组元素进行排序...
HappyTree 2006-10-13
  • 打赏
  • 举报
回复
以前尝试过这个问题,但没有找到解决方法。
Windows和Linux提供的获取文件名的顺序都是按文件名排序的先后来的,
只有取得文件信息之后才能获得该文件的创建时间。

64,643

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧