direct.h documentation

11,343

Solution 1

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

Solution 2

dirent.h is header which works cross platform. So I would recommend to use it instead of some Windows functions. On some compilers it's not included as a standart header, for example Visual Studio but you can use it. You need to download it from here. Save it in your compiler includes directory. Also, you can save it somewhere else, but in this case you need to add include path in compiler setting.

Share:
11,343

Related videos on Youtube

kjh
Author by

kjh

Updated on June 25, 2022

Comments

  • kjh
    kjh almost 2 years

    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++?