The Stream Class
The Stream class is the root of the C# stream programming. This article describe the properties and methods of this class.
The Stream class is abstract, thus it's impossible to instanciate it. But, as all the streaming classes derive from it, this class describe every functions that a streaming class should implement.
|Object -> Stream
|Indicates if read operations are allowed
|Indicates if seeking is allowed on the stream
|Indicates if write operations are allowed
|Return true if datas are available on the stream
|Length of the data available
|The current position in the stream
|int Read(byteb, int offset, int n)
|Read n bytes and store them, from the offset displacement, in the byte array b. Read return the number of bytes read or -1 if no data is available.
|Read one byte from the stream and return the value of this byte. ReadByte return -1 if the end of the stream has been reached.
|int Write(byte b, int offset, int n)
|Write in the stream the n bytes from the buffer b. These bytes are written in the stream starting from the offset position.
|void WriteByte(byte b)
|Write byte b in the stream at the current position.
|Close the stream.
|Force the writing of all the data that may be present in a buffer.
|long Seek(long offset, SeekOrigin orig)
|Set the current position in the stream. The position is given by offset, this offset may be specified from SeekOrigin.Begin (the start of the stream), SeekOrigin.Current (the current position) or SeekOrigin.End (the end of the stream)