How to VB.NET BinaryReader

BinaryReader Object works at lower level of Streams. BinaryReader is used for read premitive types as binary values in a specific encoding stream. Binaryreader Object works with Stream Objects that provide access to the underlying bytes. For creating a BinaryReader Object , you have to first create a FileStream Object and then pass BinaryReader to the constructor method.

The main advantages of Binary information is that stores files as Binary format is the best practice of space utilization.

Imports System.IO
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
        Dim readStream As FileStream
        Dim msg As String
readStream = New FileStream("c:\testBinary.dat", FileMode.Open)
            Dim readBinary As New BinaryReader(readStream)
            msg = readBinary.ReadString()
        Catch ex As Exception
        End Try
    End Sub
End Class

BinaryWriter you can use in the same way to write as binary. (C) 2021    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.
SiteMap  | Terms  | About