Read all text in a text file by using StreamReader : StreamReader « Stream File « VB.Net Tutorial






Imports System.IO
Module Module1

    Sub Main()
        Dim SourceFile As StreamReader

        Try
            SourceFile = New StreamReader("test.txt")

            Console.WriteLine(SourceFile.ReadToEnd())

            SourceFile.Close()
        Catch Except As Exception
            Console.WriteLine("Debug file does not yet exist")
        End Try

    End Sub

End Module


     Java examples (example source code) Organized by topic 
        
    
    
    
    
...








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