Reading text file using vb.net in windows application, Reading text file using io stream in .net

21 January 2012

You can read the Text File using the Below mentioned Code in vb.net and also in the windows application :

Dim LineOfText As String
Try
Dim StreamToDisplay As StreamReader
StreamToDisplay = My.Computer.FileSystem.OpenTextFileReader(Trim(BatchNo & ""))
'Here The Text File Reader is opened by taking its path
Do Until StreamToDisplay.EndOfStream
 
'Here by using the loop we can read the text file until it reaches the end of file
LineOfText = StreamToDisplay.ReadLine()
'Here you can read the line
LineOfText = LineOfText & vbCrLf
TextBox1.Text &= LineOfText
Loop
Catch ex As Exception
End Try

0 comments:

Post a Comment