Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here is how you do it (this is all from memory so there may be errors):</p> <pre><code>void FindFilesRecursively(LPCTSTR lpFolder, LPCTSTR lpFilePattern) { TCHAR szFullPattern[MAX_PATH]; WIN32_FIND_DATA FindFileData; HANDLE hFindFile; // first we are going to process any subdirectories PathCombine(szFullPattern, lpFolder, _T("*")); hFindFile = FindFirstFile(szFullPattern, &amp;FindFileData); if(hFindFile != INVALID_HANDLE_VALUE) { do { if(FindFileData.dwFileAttributes &amp; FILE_ATTRIBUTE_DIRECTORY) { // found a subdirectory; recurse into it PathCombine(szFullPattern, lpFolder, FindFileData.cFileName); FindFilesRecursively(szFullPattern, lpFilePattern); } } while(FindNextFile(hFindFile, &amp;FindFileData)); FindClose(hFindFile); } // Now we are going to look for the matching files PathCombine(szFullPattern, lpFolder, lpFilePattern); hFindFile = FindFirstFile(szFullPattern, &amp;FindFileData); if(hFindFile != INVALID_HANDLE_VALUE) { do { if(!(FindFileData.dwFileAttributes &amp; FILE_ATTRIBUTE_DIRECTORY)) { // found a file; do something with it PathCombine(szFullPattern, lpFolder, FindFileData.cFileName); _tprintf_s(_T("%s\n"), szFullPattern); } } while(FindNextFile(hFindFile, &amp;FindFileData)); FindClose(hFindFile); } } </code></pre> <p>So you could call this like</p> <pre><code>FindFilesRecursively(_T("C:\\WINDOWS"), _T("*.wav")); </code></pre> <p>to find all the *.wav files in C:\WINDOWS and its subdirectories.</p> <p>Technically you don't have to do two FindFirstFile() calls, but I find the pattern matching functions Microsoft provides (i.e. PathMatchFileSpec or whatever) aren't as capable as FindFirstFile(). Though for "*.wav" it would probably be fine.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload