Here we use StreamWriter to append lines of text to a file. This is more efficient than reading in the entire file—only the last part of the file needs to be accessed.
Imports System.IO
Module Module1
Sub Main()
' Append the first line of text to a new file.
Using writer As StreamWriter =
New StreamWriter(
"C:\append.txt", True)
writer.WriteLine(
"First line appended; 1")
End Using
' Append the second line.
Using writer As StreamWriter =
New StreamWriter(
"C:\append.txt", True)
writer.WriteLine(
"Second line appended; 2")
End Using
End Sub
End Module
First line appended; 1
Second line appended; 2