Open a file with exception handling : FileStream : File Directory Stream C# Examples


C# Examples » File Directory Stream » FileStream »

 

Open a file with exception handling









    
FileStream  fin;  
  
try  {  
    fin  =  new  FileStream("test.dat",  FileMode.Open);  
}  
catch(FileNotFoundException  exc)  {  
    Console.WriteLine(exc.Message);  
    return;  
}  
catch  {  
    Console.WriteLine("Cannot  open  file.");  
    return;  
}
    
   
  
   




HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo File Directory Stream
» FileStream