c++windows

C++ open folder and fetch for subfolder


I'm finding a way to fetch all the subfolders in a known folder, and open them, then keep finding all the subfolders in that folder, keep opening them until there aren't any subfolders left more, then move to another folder in C++. Thanks for help!


Solution

  • Following up on Serge Ballesta's comment.

    If you can compile c++17, then make use of std::filesystem.

    However, if you are not able to run c++17, then you need to consider the OS you are working on.

    If Linux and using GCC, use native "dirent.h"

    If Windows, can use either windows.h or use a popular library extension of dirent.h for windows.