C# Program to Create a Directory Last Updated : 30 Nov, 2021 Summarize Comments Improve Suggest changes Share Like Article Like Report A directory is a file system that stores file. Now our task is to create a directory in C#. We can create a directory by using the CreateDirectory() method of the Directory class. This method is used to create directories and subdirectories in a specified path. If the specified directory exists or the given path is invalid then this method will not create a directory. To use CreateDirectory() method we have to import the system.IO namespace in the program. Syntax: public static System.IO.DirectoryInfo CreateDirectory (string path); Parameter: path is the directory path. Return: This will return the object of the specified created directory. Exception: It will throw the following exception: IOException: This exception occurs when the directory specified by path is a file.UnauthorizedAccessException: This exception occurs when the caller does not have the required permission.ArgumentException: This exception occurs when the path is prefixed with, or contains, only a colon character (:).ArgumentNullException: This exception occurs when the path is null.PathTooLongException: This exception occurs when the specified path, file name, or both exceed the system-defined maximum length.DirectoryNotFoundException: This exception occurs when the specified path is invalid NotSupportedException: This exception occurs when the path contains a colon character(:) that is not part of a drive label ("D:\").Example: C# // C# program to illustrate how // to create directory using System; using System.IO; class GFG{ public static void Main() { // Create directory named Sravan in C drive // Using CreateDirectory() method Directory.CreateDirectory("C:\\sravan"); Console.WriteLine("Created"); } } Output: Created Comment More infoAdvertise with us Next Article C# Program to Get Root Directory of Given Directory S sravankumar_171fa07058 Follow Improve Article Tags : C# C# Programs CSharp-File-Handling Similar Reads C# Program to Get Complete Path of Current Directory Given a directory, now our task is to find the path of the given directory or current directory. So to this task, we use the GetCurrentDirectory() method of the Directory class. This method will return the complete path of the current directory. The result given by this method will not end with a ba 1 min read C# Program to Get Root Directory of Given Directory Directory class provides different types of methods for creating, moving, deleting, renaming, and modifying directories and subdirectories. GetDirectoryRoot() is a method of Directory class. This method is used to find the information of the volume or root or both for the given path. Or we can say t 2 min read C# Program to Check Given Directory Exists or not Given a directory, now our task is to check given directory exists or not. So to this task, we use the Exists() method of the Directory class. This method will return true if the given directory exists, otherwise false. Syntax: public static bool Exists (string? Mypath); Where, Mypath is a parameter 2 min read C# Program to Demonstrate the Use of CreateSubdirectory Method DirectoryInfo class provides different types of methods and properties that are used to perform operations on directories and sub-directories like creating, moving, etc. This class has a CreateSubdirectory() method that is used to create a sub-directory or sub-directories on the given path. Here the 2 min read C# Program to Demonstrate the Use of FullName Property DirectoryInfo class provides different types of methods and properties that are used to perform operations on directories and sub-directories like creating, moving, etc and FullName property is one of them. This property is used to find the full path of the directory or the specified file. Syntax: p 1 min read C# Program to Show the Use of Exists Property DirectoryInfo class provides different types of methods and properties for creating, moving, deleting, renaming, and modifying directories and subdirectories. Exists property is the property of DirectoryInfo class. This property is used to check whether a directory exists or not and return the boole 1 min read Like