Archived

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

stefu

Enumerating Folders

Recommended Posts

stefu    120
  

// 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
stefu    120
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
GayleSaver    122
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