Archived

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

Enumerating Folders

This topic is 5975 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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