Stream


The following table describes the Stream class’s most useful properties.

Open table as spreadsheet

Property

Purpose

CanRead

Returns True if the stream supports reading.

CanSeek

Returns True if the stream supports seeking to a particular position in the stream.

CanTimeout

Returns True if the stream supports timeouts.

CanWrite

Returns True if the stream supports writing.

Length

Returns the number of bytes in the stream.

Position

Returns the stream’s current position in its bytes. For a stream that supports seeking, the program can set this value to move to a particular position.

ReadTimeout

Determines the stream’s read timeout in milliseconds.

WriteTimeout

Determines the stream’s write timeout in milliseconds.

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

Open table as spreadsheet

Method

Purpose

BeginRead

Begins an asynchronous read.

BeginWrite

Begins an asynchronous write.

Close

Closes the stream and releases any resources it uses (such as file handles).

EndRead

Waits for an asynchronous read to finish.

EndWrite

Ends an asynchronous write.

Flush

Flushes data from the stream’s buffers into the underlying storage medium (device, file, and so on).

Read

Reads bytes from the stream and advances its position by that number of bytes.

ReadByte

Reads a byte from the stream and advances its position by 1 byte.

Seek

If the stream supports seeking, sets the stream’s position.

SetLength

Sets the stream’s length. If the stream is currently longer than the new length, it is truncated. If the stream is shorter than the new length, it is enlarged. The stream must support both writing and seeking for this method to work.

Write

Writes bytes into the stream and advances the current position by this number of bytes.

WriteByte

Writes 1 byte into the stream and advances the current position by 1 byte.

The FileStream and MemoryStream classes add few methods to those defined by the Stream class. The most important of those are new constructors specific to the type of stream. For example, the FileStream class provides constructors for opening files in various modes (append, new, and so forth).




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