I would suggest using FindFirstFile() and FindNextFile().
sample code:
HANDLE hFind;
WIN32_FIND_DATA FindFileData;
if((hFind = FindFirstFile("C:/some/folder/*.txt", &FindFileData)) != INVALID_HANDLE_VALUE){
do{
printf("%s\n", FindFileData.cFileName);
}while(FindNextFile(hFind, &FindFileData));
FindClose(hFind);
}
This really is better, because i can use “*.txt” etc, makes it much more easier to find some specific filetypes, earlier i had to write own match function for that 😀