C File.Exists

suggest change
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");

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents