69,366
社区成员
发帖
与我相关
我的任务
分享
#include <stdio.h>
#include <io.h>
#include <memory>
void Find(char *folderPath, char *filter = "*.*")
{
size_t fullPathLen = strlen(folderPath) + strlen(filter) + 1;
char *fullPath = new char[fullPathLen];
memset(fullPath, 0, fullPathLen);
strcpy_s(fullPath, fullPathLen, folderPath);
strcat_s(fullPath, fullPathLen, filter);
_finddata_t fileData;
memset(&fileData, 0, sizeof(fileData));
intptr_t hFile = _findfirst(fullPath, &fileData);
do
{
printf("%s%s%c\r\n", folderPath, fileData.name, fileData.attrib & _A_SUBDIR ? '\\' : ' ');
} while (_findnext(hFile, &fileData) == 0);
}
int main()
{
Find("F:\\downloads\\");
return 0;
}