1
1
---
2
2
title : " 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"
4
5
ms.assetid : f7cc5f5e-a541-4e00-87c7-a3769ef6096d
5
6
---
6
7
# File System Navigation
@@ -48,14 +49,14 @@ The path class has several methods that return information about various parts o
48
49
49
50
``` cpp
50
51
// filesystem_path_example.cpp
51
- // compile by using: /EHsc
52
+ // compile by using: /EHsc /W4 /permissive- /std:c++17 (or /std:c++latest)
52
53
#include < string>
53
54
#include < iostream>
54
55
#include < sstream>
55
56
#include < filesystem>
56
57
57
58
using namespace std ;
58
- using namespace std ::experimental:: filesystem;
59
+ using namespace std ::filesystem;
59
60
60
61
wstring DisplayPathInfo()
61
62
{
@@ -82,7 +83,7 @@ wstring DisplayPathInfo()
82
83
return wos.str();
83
84
}
84
85
85
- int main (int argc, char * argv [ ] )
86
+ int main ()
86
87
{
87
88
wcout << DisplayPathInfo() << endl;
88
89
// wcout << ComparePaths() << endl; // see following example
@@ -152,18 +153,18 @@ A `path` object is implicitly convertible to `std::wstring` or `std::string`. Th
152
153
153
154
``` cpp
154
155
// filesystem_path_conversion.cpp
155
- // compile by using: /EHsc
156
+ // compile by using: /EHsc /W4 /permissive- /std:c++17 (or /std:c++latest)
156
157
#include < string>
157
158
#include < iostream>
158
159
#include < fstream>
159
160
#include < filesystem>
160
161
161
162
using namespace std ;
162
- using namespace std ::experimental:: filesystem;
163
+ using namespace std ::filesystem;
163
164
164
- int main(int argc, char * argv [ ] )
165
+ int main()
165
166
{
166
- wchar_t* p = L"C:/Users/Public/Documents";
167
+ const wchar_t* p{ L"C:/Users/Public/Documents" } ;
167
168
path filePath(p);
168
169
169
170
filePath /= L"NewFile.txt";
0 commit comments