C File.Exists
suggest changeusing 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");
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents