BinaryReader and BinaryWriter


These are stream helper classes that make it easier to read and write data in specific formats onto an underlying stream. The following table describes the BinaryReader class’s most useful methods.

Open table as spreadsheet

Method

Purpose

Close

Closes the BinaryReader and its underlying stream.

PeekChar

Reads the reader’s next character, but does not advance the reader’s position, so other methods can still read the character later.

Read

Reads characters from the stream and advances the reader’s position.

ReadBoolean

Reads a Boolean from the stream and advances the reader’s position by 1 byte.

ReadByte

Reads a byte from the stream and advances the reader’s position by 1 byte.

ReadBytes

Reads a number of bytes from the stream into a byte array and advances the reader’s position by that number of bytes.

ReadChar

Reads a character from the stream and advances the reader’s position according to the stream’s encoding and the character.

ReadChars

Reads a number of characters from the stream, returns the results in a character array, and advances the reader’s position according to the stream’s encoding and the number of characters.

ReadDecimal

Reads a decimal value from the stream and advances the reader’s position by 16 bytes.

ReadDouble

Reads an 8-byte floating-point value from the stream and advances the reader’s position by 8 bytes.

ReadInt16

Reads a 2-byte signed integer from the stream and advances the reader’s position by 2 bytes.

ReadInt32

Reads a 4-byte signed integer from the stream and advances the reader’s position by 4 bytes.

ReadInt64

Reads an 8-byte signed integer from the stream and advances the reader’s position by 8 bytes.

ReadSByte

Reads a signed byte from the stream and advances the reader’s position by 1 byte.

ReadSingle

Reads a 4-byte floating-point value from the stream and advances the reader’s position by 4 bytes.

ReadString

Reads a string from the current stream and advances the reader’s position past it. The string begins with its length.

ReadUInt16

Reads a 2-byte unsigned integer from the stream and advances the reader’s position by 2 bytes.

ReadUInt32

Reads a 4-byte unsigned integer from the stream and advances the reader’s position by 4 bytes.

ReadUInt64

Reads an 8-byte unsigned integer from the stream and advances the reader’s position by 8 bytes.

The following table describes the BinaryWriter class’s most useful methods.

Open table as spreadsheet

Name

Description

Close

Closes the BinaryWriter and its underlying stream.

Flush

Writes any buffered data into the underlying stream.

Seek

Sets the position within the stream.

Write

Writes a value into the stream. This method has many overloaded versions that write characters, arrays of characters, integers, strings, unsigned 64-bit integers, and so on.




Visual Basic 2005 with  .NET 3.0 Programmer's Reference
Visual Basic 2005 with .NET 3.0 Programmer's Reference
ISBN: 470137053
EAN: N/A
Year: 2007
Pages: 417

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net