Someone1611
Someone1611

Reputation: 75

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!

Upvotes: 0

Views: 347

Answers (1)

Frebreeze
Frebreeze

Reputation: 212

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"

  • SO post with solution.
  • Just need to #include dirent.h

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

  • If using windows.h native methods, here is a SO post with solution.

  • If using windows extended dirent.h. Here is the github link. Just need to grab the header and add to your project.

    • Can be nicer if working cross platform
    • I just used this on my project, and was very convenient and easy.

Upvotes: 1

Related Questions