Jump to content
  • Advertisement

Archived

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

J-Baby

List of files in a directory?

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

Hi all, Is there a function in Visual C++ (6.0) that will return the list of files in a directory? Thank you, John

Share this post


Link to post
Share on other sites
Advertisement
You need to look up three specific Win32 functions: FindFirstFile, FindNextFile and FileClose. FindFirstFile takes the directory name and a WIN32_FIND_DATA structure, and returns a file handle to the directory. You can use a do while loop, with FindNextFile as the condition, to loop through all the directories and files in the directory, and use the contents of the WIN32_FIND_DATA structure each time to determine if what''s found is a directory or a file, it''s name, creation date, and other details. Simply call FileClose with the handle to finish reading that directory.

The argument you specify to FindFirstFile also specifies the file type to search for, eg. "c:\\mydir\\*.*", or "c:\\mydir\\*.txt". If you need any more info, drop a post here...

Insert [CENSORED] here.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!