Save all the files names from a directorie in an array
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!
Quote:Original post by guviduQuick answer: No.
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!
Long answer: Not in a platform independant way, but there are various OS specific ways. Check out FindFirstFile if you're using Win32.
You may want to take a look at the Boost Filesystem library. It is cross-platform, and I have found it to be easy to use.
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
[edit] beaten to it... I should've known that'd happen :P
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.
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.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement