Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

when I try and use std::filesystem in vs 2019 I get an error

I am using Microsoft Visual Studio 2019, and whenever I type std::filesystem there's a red bar under "filesystem", with the messages

namespace "std" has no member "filesystem"

and

name followed by '::' must be a class or namespace name

when I don't have "::" in front of it and when I do respectively.

I have included filesystem so I don't see why it doesn't work.

I hope I provided enough information, if not just ask in the comments. if you can't help me with that, maybe you could help me find an alternative to std::filesystem::recursive_directory_iterator.

like image 901
Itay123 Avatar asked Oct 29 '25 14:10

Itay123


1 Answers

The filesystem library was added in C++17 and VS2019 starts in C++14 mode by default.

  • Open Project\<project name> Properties
  • Select Configuration Properties\General
  • To the right, there is a field named C++ Standard, select one of these:
    • ISO C++17 Standard (/std:c++17)
    • Preview - Features from the latest C++ working draft (/std:c++latest)

Then #include <filesystem> and you should be good to go.

like image 64
Ted Lyngmo Avatar answered Oct 31 '25 05:10

Ted Lyngmo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!