First 包含 .h 檔:
#include <direct.h>
定義:
struct _finddata_t ff;
long hFind;
hFind = _findfirst(searchPath, &ff); //searchPath 是全路徑
if(!hFind) //如 hFind = 0, 則沒找到
exit(0);//or return or dod whatever
do{
//找到的檔案在 ff.name 裡, 但只有檔案, 沒有路徑
} while( !_findnext(hFind, &ff ) );
_findclose(hFind);
本文介绍了如何使用C语言中的_findfirst函数来搜索指定路径下的文件。通过定义结构体_finddata_t并利用_findfirst和_findnext函数,可以遍历指定路径下的所有文件。文章提供了完整的示例代码,并解释了如何处理搜索过程中遇到的各种情况。

被折叠的 条评论
为什么被折叠?



