From the course: C# and .NET Essential Training
Unlock the full course today
Join today to access over 23,200 courses taught by industry experts.
Working with directories - C# Tutorial
From the course: C# and .NET Essential Training
Working with directories
- [Instructor] Directories are very similar to files in that they can be created and deleted and they have their own sets of information about them, but they don't directly contain data the same way that files do. Directories are mainly an organizational mechanism. They give us ways of organizing collections of files and other directories. So in this example, we'll take a look at some of the features that make working with directories easier. So first, just like with files, creating and deleting directories is pretty simple. So let's open up the code here in the Directories folder. And what I'm going to do is write if not directory dot exists, and you can see that I have a variable here named dirname which is going to be my test directory name. So if that doesn't already exist, then let's create it. We'll call Directory.CreateDirectory and if it does exist, then let's delete it. So let's go ahead and run this, open this…
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.