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.
Deleting folders - C# Tutorial
From the course: C# File System Tips and Tricks
Deleting folders
- [Instructor] Now that we've created all the folders we need for our program let's take a look at how we can remove the temporary directory when the program exits. We're going to add a new public method with the return type of void and we're going to call this delete temp. We'll need to get a reference to the temporary directories so let's create a variable called temp directory. We'll set this equal to the folders array and pass in index of two for the last item. Now we can call the directory classes delete method and pass in the temp directory. Inside of our static main method after console dot read we can now call app delete temp. Now when we exit our program it'll automatically delete the temporary folder. Let's save this and run it and take a look. You'll see all of our folders exist based on our previous example. If we now hit return and go to the solution explorer and hit refresh the temporary folder will disappear. If we rerun this we should now see that both our workspace…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.