Your applications will often need to perform input and output with files and directories in different environments. The System
and System.IO
namespaces contain classes for this purpose.
In Visual Studio 2017, press Ctrl + Shift + N or choose File
| New
| Project...
.
In the New Project
dialog, in theInstalled
list, select .NET Core
. In the center list, select Console App (.NET Core)
, type Name
as WorkingWithFileSystems
, change the location to C:\Code
, type the solution name as Chapter09
, and then click on OK
.
In Visual Studio Code, in Integrated Terminal
, make a new directory named Chapter09
and a subdirectory named WorkingWithFileSystems
. Open the folder and enter the dotnet new console
command.
At the top of the Program.cs
file, add the following import statements. Note that we will statically import the Directory
, Path
, and Environment
types to simplify our code:
using static System.Console; using System.IO; using...