Sign in to follow this  
guvidu

Save all the files names from a directorie in an array

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this