VB.Net Tutorial/Stream File/BinaryReader

Материал из VB Эксперт
Перейти к: навигация, поиск

Read by using BinaryReader

Imports System.IO

Public Class Tester
    Public Shared Sub Main
        Dim fs As System.IO.FileStream
        Dim r As System.IO.BinaryReader
        Dim buffer(100) As Char
        Dim mylength As Long
        fs = New System.IO.FileStream("test.txt", IO.FileMode.OpenOrCreate)
        r = New System.IO.BinaryReader(fs)
        mylength = fs.Length
        If mylength > 100 Then
            mylength = 100
        End If
        r.Read(buffer, 0, mylength)
        Console.WriteLine(buffer)
        r.Close()
        fs.Close()
    End Sub
End Class