STREAM

The Stream class defines properties and methods that derived stream classes must provide. These let the program perform relatively generic tasks with streams such as determining whether the stream allows writing.

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

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 timing out of read and write operations.
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 number of milliseconds that a read operation will wait before timing out.
WriteTimeout Determines the number of milliseconds that a write operation will wait before timing out.

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

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, memory, and so forth).
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 one 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 one byte into the stream and advances the current position by one byte.

You can learn about the other members of the Stream class at http://msdn.microsoft.com/system.io.stream.aspx.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.139.108.22