Imports System.Text
Imports System.IO
Public Class Tester
Public Shared Sub Main
Dim myFileStream As FileStream
Dim myStreamReader As StreamReader
Dim intRead As Integer = 0
Dim chrRead As Char = ""
Dim strRead As String = ""
Try
myFileStream = New FileStream ("test.txt", FileMode.Open, FileAccess.Read)
myStreamReader = New StreamReader(myFileStream)
Do While intRead <> -1
intRead = myStreamReader.Read()
If intRead <> -1 Then chrRead = Convert.ToChar(intRead)
strRead += chrRead
Loop
Console.WriteLine(strRead)
Catch EX As IOException
Console.WriteLine(EX.Message)
End Try
End Sub
End Class
|