C# Program to Check Given Directory Exists or not Last Updated : 07 Jan, 2022 Comments Improve Suggest changes Like Article Like Report 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 of Exists() method of string type. It represents the location or path of the specified directory. Now the Exists method will return true if the given path refers to the existing directory otherwise it will return false. Return Type: The return type of this method is a boolean that is either true or false. This method will return true if the given Mypath refers to the existing directory otherwise it will return false. Example 1: C# // C# program to check whether the given // directory exists or not using System; using System.IO; class GFG{ static void Main() { // Check whether the directory named // vignan exists or not // Using Exists() method if (Directory.Exists("D:/vignan")) Console.WriteLine("The Specified directory Exists"); else Console.WriteLine("The specified directory does not Exist"); } } Output: The Specified directory ExistsExample 2: C# // C# program to check whether the given // directory exists or not using System; using System.IO; class GFG{ static void Main() { // Check whether the directory named // geeks exists or not // Using Exists() method if (Directory.Exists("D:/geeks")) Console.WriteLine("Exists"); else Console.WriteLine("Not Exist"); } } Output: Not Exist Comment More infoAdvertise with us Next Article C# Program to Check Given Directory Exists or not sravankumar_171fa07058 Follow Improve Article Tags : C# C# Programs CSharp-File-Handling Similar Reads 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 Search Sub-Directory in a Given Directory C# is a general-purpose,  object-oriented programming language pronounced as âC Sharpâ. It is a lot syntactically similar to Java and is easy for users who have knowledge of C, C++, or Java. In this article, we will learn How can we use C# to search the sub-Directory in a given Directory. So for  t 3 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 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 Create a Directory 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 t 2 min read C# Program to Delete an Empty and a Non-Empty Directory Given a directory(empty or non-empty), now we have to delete the given directory. Here, an empty directory means the directory is present without any files or subdirectories. We can define a directory as a collection of files and subdirectories, a directory may have data or not contain no data. The 4 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 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 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# Path Class - Basics Operations C# path class comes under System.IO namespace and System.Runtime.dll assembly. This class is used to perform operations on string instances that have file path or directory path information. A path is a string that holds the location of the file or directory and it can be an absolute or relative loc 3 min read Like