C++获取文件夹和文件信息找_findfirst,_findnext 和_findclose 方法 Binhua Liu 介绍 本文的目的是介绍C++中如何通过_findfirst,和_findclose 方法来查找文件夹中所有子文件夹和文件
本文还讨论了使用SHGetFileInfo 函数和结构体来获取文件/文件夹的详细信息
库和头文件 为了使用_findfirst,_findnext 和_findclose 方法,需要包含头文件: #include io
h 中包含大量对文件系统进行底层操作的函数
本文例子中使用了字符串宏,因此还需要包含头文件: #include 函数族和宏定义 为了适应各种不同的编译环境,Microsoft 往往对 C++函数给出多个版本的实现
_findfirst,_findnext 和以及_finddata_t 根据以下编译环境的不同给出了多种实现 1
采用多字符集或 Unicode 字符集 2
采用32 位时间或 64 位时间 3
采用32 位文件长度或64 位文件长度 所有函数实现列表如下: MBCS/ Unicode time type file length type Functions MBCS 32bit 32bit _findfirst32, _findnext32, _finddata32_t MBCS 32bit 64bit _findfirst32i64, _findnext32i64 , _finddata32i64_t MBCS 64bit 32bit _findfirst64i32, _findnext64i32 , _finddata64i32_t MBCS 64bit 64bit _findfirst64, _findnext64, __finddata64_t Unicode 32bit 32bit _w