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
Asked
Active
Viewed 1,760 times
2 Answers
3
Take a look at Boost.Filesystem, especially the basic_directory_iterator
.

Björn Pollex
- 75,346
- 28
- 201
- 283
-
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/ – Björn Pollex Jul 10 '10 at 12:01
1
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
- 123,740
- 17
- 206
- 299
-
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 Jul 10 '10 at 22:36
-
sorry again I found that it's windows application not console. is it true?? – Mohamed Jul 14 '10 at 10:07