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
2010-07-10 11:53:54
sorry I don't understand
Eng.Mohamed
2010-07-10 11:57:32
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
2010-07-10 12:01:35
+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
2010-07-10 13:38:50
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
2010-07-10 22:36:28
sorry again I found that it's windows application not console. is it true??
Eng.Mohamed
2010-07-14 10:07:06