C# file.Exists() code example
Example 1: c# check file exists
if (File.Exists(@"D:\myfile.txt")) {
Console.WriteLine("The file exists.");
}
Example 2: c# file exist
if (File.Exists("file.exe"))
{
//file exist
} else {
//does not exist
}
if (File.Exists(@"D:\myfile.txt")) {
Console.WriteLine("The file exists.");
}
if (File.Exists("file.exe"))
{
//file exist
} else {
//does not exist
}