Use FileStream to store and read file
Imports System
Imports System.IO
Public Class MainClass
Shared Sub Main()
Dim i As Integer
Dim theBytes(255) As Byte
For i = 0 To 255
theBytes(i) = CByte(i)
Next
Dim myFileStream As FileStream
Try
myFileStream = New FileStream("test.txt", FileMode.OpenOrCreate, FileAccess.Write)
myFileStream.Write(theBytes, 0, 256)
Finally
If Not (myFileStream Is Nothing) Then myFileStream.Close()
End Try
Dim theFile As FileStream
Try
theFile = New FileStream("test.txt",FileMode.Open, FileAccess.Read)
For i = 0 To (theFile.Length - 1)
Console.Write(theFile.ReadByte)
Next
Catch e As Exception
Throw e
Finally
If Not (theFile Is Nothing) Then theFile.Close()
End Try
End Sub
End Class
Related examples in the same category