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.
Cleaning up folder logic - C# Tutorial
From the course: C# File System Tips and Tricks
Cleaning up folder logic
- [Instructor] Now there's one thing that I want to do to help clean up a lot of the ways that we're accessing the folders we've predefined. While it's good to keep these folders inside of an array it's really bad to access that array directly without having some sort of protection to make sure that if the array contents change we don't break our code. Since we're working with the users files system we always want to make sure that we're creating and deleting the correct folders. To help us we're going to create a new method called public void get folder by name. Now before we add an argument to this method let's go towards the top of our class to where we define our folders array. Below this let's create a new public enum, and we're going to use this enum to store the folder names. The first name is going to be the workspace. Our second will be the archive. Next we'll use the temporary directory and finally our save data one. Now we can use the folder names enum to safely access the…
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.