16,548
社区成员




// 利用winWIN32_FIND_DATA读取文件下的文件名
void EnumFiles(const char* filePath)
{
char tempFilePath[MAX_PATH + 1];
sprintf_s(tempFilePath, "%s\\*.*", filePath);
WIN32_FIND_DATAA file;
HANDLE handle = FindFirstFileA(tempFilePath, &file);
if (handle != INVALID_HANDLE_VALUE)
{
do
{
printf("%s\n", file.cFileName);
if(0
|| strcmp(file.cFileName, ".") == 0
|| strcmp(file.cFileName, "..") == 0
|| 0) //. ..
{
continue;
}
if(file.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) //directory
{
printf("is directory\n");
continue;
}
//file ……
} while (FindNextFileA(handle, &file));
FindClose(handle);
}
}