C# Tutorials: How to check whether the File Exists in Path

By writing code as below,you can test whether the file exists or not
class Program
{
static void Main(string[] args)
{
string str = @"D:\tempByLakshmipathi\forums\q&a.txt";
if(File.Exists(str))
Console.WriteLine("Yes..File Exists");
else
Console.WriteLine("No..File does not exists");
}
}
For more details about files in DOTNET Click here

Comments