Mega Code Archive

 
Categories / VB.Net Tutorial / Stream File
 

Use FreeFile to read a text file

public class Test    public Shared Sub Main         Dim file_num As Integer = FreeFile()         Dim file_name As String = "test.txt"         FileOpen(file_num, file_name, OpenMode.Input, OpenAccess.Read, OpenShare.Shared)         Do While Not EOF(file_num)             Dim txt As String = LineInput(file_num)             Console.WriteLine(txt)         Loop         FileClose(file_num)    End Sub End class