Search code examples
c++filesystemsc++17

Filesystem not found


Any time I try to use the filesystem library, it gives me error: 'filesystem' is not a namespace-name My Code is

#include <iostream>
#include <filesystem>
namespace fs = std::filesystem;
int main()
{
    std::cout << "Current path is " << fs::current_path() << '\n';
}

I am using gcc (MinGW.org GCC Build-2) 9.2.0. Is C++ 17 not supported.

EDIT:

I found out that VS 2019 has a setting that allows you to change your C++ Language Standard.


Solution

  • Try like that:

    #include <experimental/filesystem>
    
    namespace fs = std::experimental::filesystem;