C# program to demonstrate the use of Exists property

Syntax:

bool DirectoryInfo.Exists

Program:

using System;
using System.IO;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main()
        {
            DirectoryInfo d = new DirectoryInfo("mydir");

            if(d.Exists)
                Console.WriteLine("Directory exists");
            else
                Console.WriteLine("Directory does not exists");
        }
    }
}

Output:

Directory exists

Leave a Comment

error: Alert: Content is protected!!