Advertisement Jump to content
Sign in to follow this  

files in a directory

This topic is 4934 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

how do i get a list of files in a directory (windows) in c++ preferably not using MFC because this will be in a .dll file. i just want to see what files are there, look for certain extensions and possibly recurse through child directories. ~guyaton

Share this post

Link to post
Share on other sites
Here is an example how to use it (not including error checking):
WIN32_FIND_DATA fd;//contains properties of the file
HANDLE hf = FindFirstFile (dirpath, &fd);//finds the first file in the directory
FindNextFile (hf, &fd)//find next file in directory
*The files that these functions retrieve can also be directories.
*FindNextFile returns NULL when there are no more files.
*The order which the files are retrieved is not sorted (at least i think so because when i used it i found no sorting, even the directories were mixed with the files, there weren't seperated to two groups).
Oh and by the way when using MFC you can include as a static linked library in the project settings and then you need to use no DLL.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!