How to use C# Directory Class
Directory class in CSharp exposes methods to create , delete , move etc. operations to directories and subdirectories . Because of the static nature of C# Directory class , we do not have to instantiate the class. We can call the methods in the C# Directory class directly from the Directory class itself.
How to create a directory using Directory class in C# ?
In order to create a new directory using Directory class in C# , we can call CreateDirectory method directly from Directory class.
Syntax- DirPath : The name of the new directory
How to check a directory exist or not using Directory class in C# ?
Before we creating a directory or folder , we usually check that directory or folder exist or not. In C# we are using Exists method in the Directory class.
Syntax- DirPath : The name of the directory
- bool : Returns true or false
How to move a Directory using Directory class in C# ?
If we want to move a directory and its contents from one location to another , we can use the Move method in the C# Directory class.
Syntax- sourceDirName : The source directory we want to move.
- destDirName : The destinations directory name.
How to delete a Directory using Directory class in C# ?
When we want to delete a directory we can use the Delete method in the C# Directory class.
Syntax- DirPath : The Directory we want to delete.
The following C# source code shows some operations in Directory class
Full Source C#- How to write a text file in c#
- Append text to an existing file in C#
- How to use C# File Class
- How to use C# FileStream Class
- How to use C# Textreader Class
- A simple C# Text Reader source code
- How to use C# TextWriter Class
- How to use C# BinaryWriter Class
- How to use C# BinaryReader Class
- How to convert XPS file to Bitmap
- How to C# Path Class
- How to create a pdf file in C#
- How to create PDF file from Text file
- Write Database data to pdf file