views:

75

answers:

2

I have a directory and I want to read all the text files in it using C++ and having windows OS also using console application I don't know the files' names or their number thanks in advance

+3  A: 

Take a look at Boost.Filesystem, especially the basic_directory_iterator.

Space_C0wb0y
sorry I don't understand
Eng.Mohamed
When you click the second link in my answer and scroll down a little, there is a sample application that lists all the items in a directory. If you are not able to take it from there, look at http://stackoverflow.com/questions/388242/
Space_C0wb0y
+1  A: 

If you want the C++ and portable way, follow the solution by @Space_C0wb0y and use boost.Filesystem, otherwise, if you want to get your hands dirty with the Windows APIs, you can use the FindFirstFile/FindNextFile/FindClose functions.

You can find here an example related to them.

Matteo Italia
thanks a lot friend
Eng.Mohamed
You're welcome. If you solved with this method you may mark my answer as accepted. :)Still, keep in mind that if you need portability and C++ style the best method is the one suggested by Space_C0wb0y.
Matteo Italia
sorry again I found that it's windows application not console. is it true??
Eng.Mohamed
There's no difference.
Matteo Italia