Code Repo    |     RSS
MD's Technical Sharing



Tuesday, March 24, 2009

Enumerate through all files in a folder

This can be achieved easily using the Win32 APIs FindFirstFile and FindNextFile


WIN32_FIND_DATAW FindFileData;

//find the first file matching the pattern

HANDLE hFind = FindFirstFile(L"\\My Documents\\*.jpg", &FindFileData);

//find the first file, continue to find next file

if (hFind != INVALID_HANDLE_VALUE)

{

printf("%S", FindFileData.cFileName);

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

{

}

FindClose(hFind);

}

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.