Pretty new here in the C++ world as I am more familiar with C#. I managed to get findfirstfile and findnextfile to work but i'm wondering if there is a simple way of searching thru different drives or even just subdirectories.
Thanks!
Yes, try to use std::filesystem, for example like this
std::string tasksFolderName = "/home/user";
std::experimental::filesystem::directory_iterator fit(tasksFolderName);
for (auto& f : fit) {
if (std::experimental::filesystem::is_directory(f.path())) {
// ...
}
}
for (auto& p : std::filesystem::directory_iterator(<Directory to iterate>))
std::cout << p.path() << '\n';
You can use above code. To use this you need a compiler which supports c++17. You can read more about Filesystem library which is introduced in c++17.
Hope this will help.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.