Jump to content
  • Advertisement
Sign in to follow this  
guvidu

Save all the files names from a directorie in an array

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

Hy there! I need to save all the files names from a directory in an array ? Is there a way to do that in C++? Thanks!

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by guvidu
Hy there!

I need to save all the files names from a directory in an array ? Is there a way to do that in C++?

Thanks!
Quick answer: No.
Long answer: Not in a platform independant way, but there are various OS specific ways. Check out FindFirstFile if you're using Win32.

Share this post


Link to post
Share on other sites
Doesnt really help me but thanks - at least i got my answer - i have to find another way:P

Share this post


Link to post
Share on other sites
Didn't boost::filesystem implement directory and files iterators that permitted you to do this while being portable on some (but maybe not all) platforms?

[edit] beaten to it... I should've known that'd happen :P

Share this post


Link to post
Share on other sites
Or, put differently:

You can use C++ to iterate through files. What you do with them is up to you (you can find out the filename, and store that in an array).

But the methods are generally not portable, so there is no one answer.

If you describe the OS you're using, then it's possible to give an answer.

Boost is one way of doing it in portable fashion.

Share this post


Link to post
Share on other sites
Quote:
Original post by Evil Steve
Quick answer: No.
Long answer: Not in a platform independant way, but there are various OS specific ways. Check out FindFirstFile if you're using Win32.


He gave you the Windows answer right here.

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!