Skip to content

Commit 7308038

Browse files
author
Colin Robertson
committed
Fix broken examples in filesystem navigation
1 parent f18e7e7 commit 7308038

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

docs/standard-library/file-system-navigation.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
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"
45
ms.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

5758
using namespace std;
58-
using namespace std::experimental::filesystem;
59+
using namespace std::filesystem;
5960

6061
wstring 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

161162
using 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

Comments
 (0)