Hi all! I use WTL + winapi. I need to obtain a list of files from a specified directory, including files from all subdirectories. I wrote a function, but it doesn't work correcty...
We start to search files, when we found an subdir, we set it as current direcotory, and call recursively my function for that dir. But when I'm turning back to root dir, it starts from beginnig, but doesn't continue the search, by skiping last founded subdir.
Here is the code:
Thx for your answers!
void GetAllFiles(char* str, CListBox cLb)
HANDLE hSearch = NULL;
::MessageBox(NULL, str, "CurDir", 0);
for (hSearch = FindFirstFile("*.*", &wfd); FindNextFile(hSearch, &wfd);)
if (strcmp(wfd.cFileName, ".") == 0) continue; /* current dir */
if (strcmp(wfd.cFileName, "..") == 0) continue; /* parent dir */
if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
::MessageBox(NULL, str, "Folder:: ", 0);
if( strcmp(str, szFolderPath) )//Esli nado vyshe
str[ strlen(str) - strlen(wfd.cFileName) ] = '\0';