Reads and Displays Only The First Line: Before Module
Reads and Displays Only The First Line: Before Module
Imports System
Imports System.IO
Reading the first line from a file named text located on the Desktop [Reads and
displays |on console| only the first line]:
Dim file As StreamReader
Dim text As String
file = New StreamReader("C:\Users\Daud Cheema\Desktop\text.txt")
text = File.ReadLine()
Console.WriteLine(text)
Console.ReadLine()
file.Close()
Reading all the lines from a file named text located on the Desktop [Reads and displays
|on console| all the lines till the text in the file finishes]:
Dim file As StreamReader
Dim text As String
file = New StreamReader("C:\Users\Daud Cheema\Desktop\text.txt")
Writing to a file named text located on the Desktop [This will remove all text present in the file,
if any and replace it with the one input by the user]: