StreamReader: Peek : StreamReader « Stream File « VB.Net Tutorial






Imports System.IO

Public Class Tester
    Public Shared Sub Main
        Dim fsStream As New FileStream("test.txt", FileMode.Open, FileAccess.Read)
        Dim srReader As New StreamReader(fsStream)

        Try
            srReader.BaseStream.Seek(0, SeekOrigin.Begin)
            While srReader.Peek() > -1
                Console.WriteLine(srReader.ReadLine())
            End While
            srReader.Close()
        Catch ex As IOException
            Console.WriteLine(ex.Message)
        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