Check if file exists using C#

Posted by Prince | 8:35:00 PM | | 0 comments »


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;
 }
}

0 comments

Related Posts Plugin for WordPress, Blogger...