C# Program to Create a Directory Last Updated : 30 Nov, 2021 Comments Improve Suggest changes 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 Create a Directory 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 Get Computer Drive Names of Given Directory Directory class provides different types of methods for creating, moving, deleting, renaming, and modifying directories and subdirectories. GetLogicalDrives() is the method of the Directory class. This method is used to find the name of the logical drive names present in the computer. Or we can say 2 min read C# Program to Get the List of Sub-Directories of a Given Directory Given a director, now we will find the list of the sub-directories present in the given directory. So to this task, we use the GetDirectories() method of the Directory class. This method is used to get the list of directories/sub-directories from the given directory or sub-directories. We have to sp 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 How to Create a Directory in Java? In Java, creating a directory is a common operation when working with file system manipulation. Directories are used to organize files and other directories into a hierarchical structure. This article will guide you through the process of creating a directory in Java, providing step-by-step examples 2 min read Python Program to Safely Create a Nested Directory Creating a nested directory in Python involves ensuring that the directory is created safely, without overwriting existing directories or causing errors. To create a nested directory we can use methods like os.makedirs(), os.path.exists(), and Path.mkdir(). In this article, we will study how to safe 2 min read Like