11---
22title : " File System Navigation"
3- ms.date : " 11/04/2016"
3+ description : " How to use the C++ Standard library filesystem APIs to navigate the file system."
4+ ms.date : " 04/13/2020"
45ms.assetid : f7cc5f5e-a541-4e00-87c7-a3769ef6096d
56---
67# File System Navigation
@@ -48,14 +49,14 @@ The path class has several methods that return information about various parts o
4849
4950``` cpp
5051// filesystem_path_example.cpp
51- // compile by using: /EHsc
52+ // compile by using: /EHsc /W4 /permissive- /std:c++17 (or /std:c++latest)
5253#include < string>
5354#include < iostream>
5455#include < sstream>
5556#include < filesystem>
5657
5758using namespace std ;
58- using namespace std ::experimental:: filesystem;
59+ using namespace std ::filesystem;
5960
6061wstring DisplayPathInfo()
6162{
@@ -82,7 +83,7 @@ wstring DisplayPathInfo()
8283 return wos.str();
8384}
8485
85- int main (int argc, char * argv [ ] )
86+ int main ()
8687{
8788 wcout << DisplayPathInfo() << endl;
8889 // wcout << ComparePaths() << endl; // see following example
@@ -152,18 +153,18 @@ A `path` object is implicitly convertible to `std::wstring` or `std::string`. Th
152153
153154``` cpp
154155// filesystem_path_conversion.cpp
155- // compile by using: /EHsc
156+ // compile by using: /EHsc /W4 /permissive- /std:c++17 (or /std:c++latest)
156157#include < string>
157158#include < iostream>
158159#include < fstream>
159160#include < filesystem>
160161
161162using namespace std ;
162- using namespace std ::experimental:: filesystem;
163+ using namespace std ::filesystem;
163164
164- int main(int argc, char * argv [ ] )
165+ int main()
165166{
166- wchar_t* p = L"C:/Users/Public/Documents";
167+ const wchar_t* p{ L"C:/Users/Public/Documents" } ;
167168 path filePath(p);
168169
169170 filePath /= L"NewFile.txt";
0 commit comments