Read Text file in Visual Basic using StreamReader

Sub ReadLines()
Dim fileName As String = "c:\data\test.txt"
Dim delimiter As String = ","
Dim sr As New System.IO.StreamReader(fileName)

Try
While sr.Read() >= 0
Dim r As String = sr.ReadLine()
Console.WriteLine(r)
End While
Finally
sr.Close()
sr.Dispose()

End Try
End Sub

Leave a Reply

Your email address will not be published. Required fields are marked *