BinaryReader.ReadByte reads the next byte from the current stream : Binary File Read « File Directory « VB.Net

Home
VB.Net
1.2D
2.Application
3.Class
4.Data Structure
5.Data Types
6.Database ADO.net
7.Date Time
8.Development
9.Event
10.File Directory
11.Generics
12.GUI
13.Internationalization I18N
14.Language Basics
15.LINQ
16.Network Remote
17.Reflection
18.Security
19.Thread
20.Windows Presentation Foundation
21.Windows System
22.XML
23.XML LINQ
VB.Net Tutorial
VB.Net by API
VB.Net » File Directory » Binary File ReadScreenshots 
BinaryReader.ReadByte reads the next byte from the current stream
 

Imports System
Imports System.IO

Public Class BinaryRW
    Shared Sub Main()
        Dim As Integer = 0
        Dim writeArray(1000As Byte
        Dim randomGenerator As New Random()
        randomGenerator.NextBytes(writeArray)

        Dim binWriter As New BinaryWriter(New MemoryStream())
        Dim binReader As New BinaryReader(binWriter.BaseStream)
        Try
            For i = To writeArray.Length - 1
                binWriter.Write(writeArray(i))
            Next i
            binReader.BaseStream.Position = 0
            For i = To writeArray.Length - 1
                If binReader.ReadByte() <> writeArray(iThen
                    Console.WriteLine("Error writing the data.")
                    Return
                End If
            Next i
        Catch ex As EndOfStreamException
            Console.WriteLine("Error writing the data: {0}",ex.GetType().Name)
        End Try

    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.ReadBytes reads the specified number of bytes
7.BinaryReader.ReadChar reads the next character from the stream
w__w___w__.___ja__va___2__s_.___c___om | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.