BinaryReader.Read reads the specified number of characters from the stream : Binary File Read « File Directory « VB.Net






BinaryReader.Read reads the specified number of characters from the stream

 

Imports System
Imports System.IO

Public Class BinaryRW

    Shared Sub Main()

        Dim invalidPathChars() As Char = Path.InvalidPathChars
        Dim memStream As new MemoryStream()
        Dim binWriter As New BinaryWriter(memStream)

        binWriter.Write("Invalid file path characters are: ")
        binWriter.Write(Path.InvalidPathChars, 0, _
            Path.InvalidPathChars.Length)

        Dim binReader As New BinaryReader(memStream)

        memStream.Position = 0

        Console.Write(binReader.ReadString())
        Dim upperBound As Integer = CInt(memStream.Length - memStream.Position) - 1
        Dim memoryData(upperBound) As Char
        binReader.Read(memoryData, 0, upperBound)
        Console.WriteLine(memoryData)

    End Sub
End Class

   
  








Related examples in the same category

1.Reading a sequential-access fileReading a sequential-access file
2.Read and Write Binary file: int, string Read and Write Binary file: int, string
3.Read from a binary fileRead from a binary file
4.Check Files Are Identical
5.BinaryReader.ReadByte reads the next byte from the current stream
6.BinaryReader.ReadBytes reads the specified number of bytes
7.BinaryReader.ReadChar reads the next character from the stream