Save all the files names from a directorie in an array

Started by
7 comments, last by SavagePencil 16 years, 10 months ago
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!
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.
Doesnt really help me but thanks - at least i got my answer - i have to find another way:P
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
Thanks - i will take a look!
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.
I want to do it for windows xp - vista!
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