The following function:
void foo(const std::string& dir)
{
for (auto& el : std::filesystem::recursive_directory_iterator(dir)) {
std::cout << el.path() << '\n';
}
}
when used in:
int main()
{
std::string p = "C:\\";
foo(p);
}
raises an exception when it reaches a certain folder (I assume) on Windows 10. The code is compiled on VS 2017 with C++17 support. The exception message is:
recursive_directory_iterator::operator++: The system cannot find the path specified.
The same behavior occurs when using the std::filesystem::directory_iterator too.
Why is it raising an exception on that particular folder?