#include <windows.h>
#include <stdio.h>
int main() {
HANDLE file;
LPCTSTR wtFileName="特定文件\\*.*";
//命名规则 xx\\*.*
WIN32_FIND_DATA pNextInfo;
file=FindFirstFile(wtFileName, &pNextInfo);
if (file == INVALID_HANDLE_VALUE)
{
cout<<"搜索失败"<<endl;
system("pause");
exit(0);
}
cout<<"得到文件:"<<pNextInfo.cFileName<<endl;//请注意这句
int count=1;
while (FindNextFile(file, &pNextInfo))
{
if (pNextInfo.cFileName[0] == '.')
//过滤.和..
continue;
cout<<"得到文件:"<<pNextInfo.cFileName<<endl;
count++;
}
cout<<"count = "<<count<<endl;
return 0;
}