Mega Code Archive

 
Categories / VB.Net / File Directory
 

Read line by line from a text file

Option Explicit On  Option Strict On Imports System Imports System.IO Public Class TextFromFile          Public Shared Sub Main()         Using sr As StreamReader = File.OpenText("MyFile.txt")             Dim input As String             input = sr.ReadLine()             While Not input Is Nothing                 Console.WriteLine(input)                 input = sr.ReadLine()             End While             Console.WriteLine("The end of the stream has been reached.")             sr.Close()         End Using     End Sub End Class