Tuesday, 16 February 2016

C# Program how to Check the Exist of a File

using System;
using System.IO;

class Filecheck
{
    static void Main()
    {
        FileInfo info = new FileInfo("D:\\ABV\\doc.txt");
        bool exists = info.Exists;
        if (exists == true)
        {
            Console.WriteLine("The File Exists in the drive");
        }
        else
        {
            Console.WriteLine("No Such File Found");
        }
        Console.Read();
    }
}
-----------------------
OUTPUT:-   The File Exists in the drive 
---------------------------------

No comments:

Post a Comment