forked from dotnet/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsource2.vb
26 lines (24 loc) · 824 Bytes
/
source2.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
'<snippet20>
Imports System.IO
Public Class CompBuf
Private Const FILE_NAME As String = "MyFile.txt"
Public Shared Sub Main()
If Not File.Exists(FILE_NAME) Then
Console.WriteLine($"{FILE_NAME} does not exist!")
Return
End If
Dim fsIn As new FileStream(FILE_NAME, FileMode.Open, _
FileAccess.Read, FileShare.Read)
' Create an instance of StreamReader that can read
' characters from the FileStream.
Using sr As New StreamReader(fsIn)
Dim input As String
' While not at the end of the file, read lines from the file.
While sr.Peek() > -1
input = sr.ReadLine()
Console.WriteLine(input)
End While
End Using
End Sub
End Class
'</snippet20>