How to read a file line by line to the end in VB.NET

by Preetha 2012-09-14 10:00:37

Imports System.IO
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim file_dir As String = "file.txt"
'parse file
Try
Dim sr As StreamReader = New StreamReader(file_dir)
Do Until sr.EndOfStream
TextBox1.Text += vbNewLine + sr.ReadLine()
Loop
sr.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
End Class

Tagged in:

420
like
0
dislike
0
mail
flag

You must LOGIN to add comments