Imports System.IO
Imports System.Text
Public Class Tester
Public Shared Sub Main
Dim myFileStream As FileStream
Dim intByte As Integer
Dim lngLoop As Long = 0
Dim bteRead() As Byte
Try
myFileStream = File.OpenRead("test.txt")
ReDim bteRead(myFileStream.Length)
Do While Not intByte = -1
intByte = myFileStream.ReadByte()
If intByte <> -1 Then bteRead(lngLoop) = CByte(intByte)
lngLoop += 1
Loop
Console.WriteLine(Encoding.ASCII.GetString(bteRead))
myFileStream.Close()
Catch ex As IOException
Console.WriteLine(ex.Message)
End Try
End Sub
End Class
|