I'm trying to write a small block of code that prints out the files in a given directory. I've seen references to using the direct.h library to do this, but I cannot find any documentation whatsoever on the header file and its methods. Is this library outdated? And is there another way to list all filenames of a directory in C++?
- The accepted answer to stackoverflow.com/questions/6193607/cannot-find-direct-h says that direct.h is not part of the gcc compiler so depending on which compiler you are using it might not be available.ctor– ctor2012-09-30 02:01:36 +00:00Commented Sep 30, 2012 at 2:01
Add a comment |
2 Answers
It seems that this header functions are not designed for this task, See http://msdn.microsoft.com/en-us/library/as5kw0ze(v=vs.110).aspx
Use FindFirstFile, FindNextFile and FindClose loop like in this example code