C# File.Exists Method:
Exists method of the System.IO.File class can be used to check if a file exists in a given location.
Code:
private static bool IsFileExists(stringsFileName){
try
{
if (File.Exists(sFileName) == true)
{
return true;
}
else
{
return false;
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
return false;
}
}
try
{
if (File.Exists(sFileName) == true)
{
return true;
}
else
{
return false;
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
return false;
}
}
0 comments
Post a Comment