Archived

This topic is now archived and is closed to further replies.

stefu

Enumerating Folders

Recommended Posts

  

// Find first file

WIN32_FIND_DATA FindFileData;
HANDLE h = FindFirstFile( "Tracks\\*.*", &FindFileData );

// Then repeat for next files

FindNextFile(h,&FindFileData)

  
This enumerates all files, but how can I enumerate only folders? Each track has own subfolder and I need to get list of tracks.

Share this post


Link to post
Share on other sites
MSDN says FindFirstFileEx is not supported in Windows 9x!
It doesn''t compile.

But hey, I can check file attributes (_WIN32_FIND_DATA.DWORD dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY).

Share this post


Link to post
Share on other sites
By the way, FindFirstFile/FindNextFile is an iterator, so use it like this:
for (HANDLE hFind = FindFirstFile (szSpec, &wfd); GetLastError() != ERROR_NO_MORE_FILES; FindNextFile (hFind, &wfd) ) {
// Analyze wfd for each file
}
FindClose (hFind);

Share this post


Link to post
Share on other sites