Here is source code of the C# Program to Check the Existence of a File. The C# program is successfully compiled and executed with Microsoft Visual Studio. The program output is also shown below.
* C# Program to Check the Existence of a File
static void Main()
FileInfo info = new FileInfo("C:\\sri\\srip.txt");
bool exists = info.Exists;
if (exists == true)
Console.WriteLine("The File Exists");
Console.WriteLine("No Such File Found");
Here is the output of the C# Program:
Sanfoundry Global Education & Learning Series – 1000 C# Programs.
If you liked this C# Program, kindly share, recommend or like below!