Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

C# Program to Show the Use of Exists Property

  • Last Updated : 26 Jan, 2022

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 boolean value accordingly. It will return true if the directory exists, otherwise, it will return false. It will also return if any error occurs while determining if the file exists, or if the specified file is missing, or if the caller does not get permission to read the specified file.


bool DirectoryInfo.Exists



// C# program to understande the use of Exists Property
using System;
using System.IO;
class GFG{
static void Main()
    // Getting the directory information
    DirectoryInfo information = new DirectoryInfo("sravan_directory");
    // Checking whether the given directory
    // exists or not
    // Using Exists property
    if (information.Exists)
        Console.WriteLine("Not Exists");


Not Exists
My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!