Check if file exists using C# | Coding Cluster - using asp.net, c#, mvc 4, iphone, php, ios, javascript, in asp.net mvc 3 & more
 

Check if file exists using C#

Friday


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:

Post a Comment

Share your thoughts here...

 
 
 

RECENT POSTS

Boost

 
Blogger Widgets