BinaryReader.ReadChar reads the next character from the stream : Binary File Read « File Directory « VB.Net






BinaryReader.ReadChar reads the next character from the stream

 
Imports System
Imports System.IO

Public Class BinaryRW
    Shared Sub Main()
        Dim i As Integer = 0
        Dim invalidPathChars() As Char = Path.InvalidPathChars
        Dim memStream As new MemoryStream()
        Dim binWriter As New BinaryWriter(memStream)

        For i = 0 To invalidPathChars.Length - 1
            binWriter.Write(invalidPathChars(i))
        Next i

        Dim binReader As New BinaryReader(memStream)

        memStream.Position = 0

        Console.Write(binReader.ReadString())
        Dim memoryData(CInt(memStream.Length - memStream.Position) - 1) As Char
        For i = 0 To memoryData.Length - 1
            memoryData(i) = binReader.ReadChar()
        Next i
        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.Read reads the specified number of characters from the stream
6.BinaryReader.ReadByte reads the next byte from the current stream
7.BinaryReader.ReadBytes reads the specified number of bytes