Mega Code Archive

 
Categories / VB.Net Tutorial / Stream File
 

Check Exception in file reading

Imports System.IO Imports System public class Test    public Shared Sub Main         Dim sr As IO.StreamReader         Try             sr = New IO.StreamReader("test.txt")             Console.WriteLine(sr.ReadToEnd())         Catch ex As IO.FileNotFoundException             Console.WriteLine("FileNotFoundException")         Catch ex As IO.IOException             Console.WriteLine("IOException")         Catch ex As Exception             Console.WriteLine("Error Loading File")         Finally             sr.Close()         End Try    End Sub End class Hello world!