.NET Framework C# File.Exists()


Example

using System;
using System.IO;
                
public class Program
{
    public static void Main()
    {
        string filePath = "somePath";
    
        if(File.Exists(filePath))
        {
            Console.WriteLine("Exists");
        }
        else
        {
            Console.WriteLine("Does not exist");    
        }
    }
}

Can also be used in a ternary operator.

Console.WriteLine(File.Exists(pathToFile) ? "Exists" : "Does not exist");