Get subfolders function

Posted By: Puppeteer

Get subfolders function - 11/11/09 19:41

I'd like to get the names of all subfolders in a specific folder.
Is there something like a new files.dll for lite c?

Thank you very much!
Posted By: Quad

Re: Get subfolders function - 11/11/09 19:50

you can already do that with winapi.

example lite-c:
Code:
#include <acknex.h>
#include <windows.h>
int main(){
	WIN32_FIND_DATA ffd;
   HANDLE hFind = INVALID_HANDLE_VALUE;
   hFind = FindFirstFile("*", &ffd);

   while (FindNextFile(hFind, &ffd) != 0)
   {
      if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
      {
         printf("  %s   <DIR>\n", ffd.cFileName);
      }
   }
   FindClose(hFind);
}



note: this line:

FindFirstFile("c:\*", &ffd);

change c:\* to something else.(your spesific folder)
putting a * alone will list folders in current directory.

edit: apperantly findfirstfile take relative path, sorry for my mistake.
© 2023 lite-C Forums