遍历文件夹(不包含子目录)

     WIN32_FIND_DATA FindFileData;

HANDLE hFind;

TCHAR *FilePathBuff = L"C:\\TestFolder";

hFind = FindFirstFile(FilePathBuff, &FindFileData);

 

if (hFind == INVALID_HANDLE_VALUE)

{

                _tprintf(TEXT("FindFirstFile failed (%d)\n"), GetLastError());

}

else

{

                _tprintf(TEXT("The first file is %s\n"), FindFileData.cFileName);

               while (FindNextFile(hFind, &FindFileData) != 0)

                {

                                _tprintf(TEXT("The next file is %s\n"),

                                                FindFileData.cFileName);

                }

 

                FindClose(hFind);

}

你可能感兴趣的:(File)