From the course: C# File System Tips and Tricks

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Protecting the file system

Protecting the file system - C# Tutorial

From the course: C# File System Tips and Tricks

Start my 1-month free trial

Protecting the file system

- [Instructor] Now it's time for us to continue to keep routing calls to the FileSystem through our custom FileSystem class. Let's comment out the using System.IO again and go line by line through the errors to continue to see where we need to add new functionality to our class. Now, let's start adding some of the path classes logic to our FileSystem class. Here we'll copy the GetFileName method, go back into our FileSystem and create a public method with a return type of string, paste in our method name and we'll use a string path as the argument. Now, let's use a return statement and we'll call Path.GetFileName and we'll supply the path. In our program let's replace the call to the path class with our FileSystem and now let's create a getter for the directory separator character. We'll copy this value and create a new public getter with a return type of char, paste the getter's name and inside we'll use get return and call the Path.GetDirectorySeparatorChar in order to get the…

Contents