Read text file to the end : StreamReader « Stream File « VB.Net Tutorial






Imports System.IO

Public Class Tester
    Public Shared Sub Main
    
            Try
               Dim stream As StreamReader
               stream = New StreamReader("test.vb")
               Console.WriteLine(stream.ReadToEnd())
            Catch exceptionCatch As IOException
               Console.WriteLine("FILE ERROR")
            End Try

    End Sub

End Class








13.18.StreamReader
13.18.1.Create StreamReader from FileStream
13.18.2.Read text file to the end
13.18.3.Read all text in a text file by using StreamReader
13.18.4.Read text file to a char array
13.18.5.StreamReader: read to a buffer
13.18.6.StreamReader: Peek
13.18.7.Check Exception in file reading
13.18.8.Use Finally clause to close a stream