Jump to content
  • Advertisement
Sign in to follow this  
DJ14IVI3

How do I read the contents of a folder?

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

I want to scan the savegame folder for any saved game files. I thought of making an index file into which names of savegames would be written upon saving and read when accesing the load menu. This would work as long as the user doesen't manualy delete any saves. But you know what are some end-users like. I'm guessing that folders are just files consisting of pointers to other files. But how do I read this type of file? Or am I missing some easy and obvious way to do it?

Share this post


Link to post
Share on other sites
Advertisement
I'm not 100% that this is what you would like to implement, but I personally use the _findfirst() and _findnext() functions:

_findfirst() accepts a root path (can just be the drive), and a pointer to a _finddata_t structure which describes the first file found which satisfies the wildcard (if given), and a handle to this search (or -1 if none are found).

After calling _findfirst(), you then repeatedly call _findnext(), passing the handle which _findfirst() returns and another _finddata_t pointer, until _findnext() returns -1 (meaning no files remain to be returned).

I know this is not a particulary concise explanation, but look these functions up in the MSDN help files or ask if you would like to know more.

P.S. This is probably an outdated method for searching for files, but its worked well enough for me for years...

[S]

Share this post


Link to post
Share on other sites
lucky you, i just got done reading the section on it.

in managed code you can DirectoryInfo and FileInfo classes in the system.io namespace.

Share this post


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

  • 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!