Namespace: System.IO
Stream
Provides a generic view of a sequence of bytes. This is an abstract class.
Properties (3)
long Length
When overridden in a derived class, gets the length in bytes of the stream.
Value: A long value representing the length of the stream in bytes.
int ReadTimeout
Gets or sets a value, in miliseconds, that determines how long the stream will attempt to read before timing out.
Value: A value, in miliseconds, that determines how long the stream will attempt to read before timing out.
int WriteTimeout
Gets or sets a value, in miliseconds, that determines how long the stream will attempt to write before timing out.
Value: A value, in miliseconds, that determines how long the stream will attempt to write before timing out.
Methods (7)
IAsyncResult BeginRead(Byte[],Int32,Int32,AsyncCallback,Object)
Begins an asynchronous read operation. (Consider using Int32) instead.)
| Parameter | Description |
|---|---|
| buffer | The buffer to read the data into. |
| offset | The byte offset in buffer at which to begin writing data read from the stream. |
| count | The maximum number of bytes to read. |
| callback | An optional asynchronous callback, to be called when the read is complete. |
| state | A user-provided object that distinguishes this particular asynchronous read request from other requests. |
Returns: An IAsyncResult that represents the asynchronous read, which could still be pending.
int EndRead(IAsyncResult)
Waits for the pending asynchronous read to complete. (Consider using Int32) instead.)
| Parameter | Description |
|---|---|
| asyncResult | The reference to the pending asynchronous request to finish. |
Returns: The number of bytes read from the stream, between zero (0) and the number of bytes you requested. Streams return zero (0) only at the end of the stream, otherwise, they should block until at least one byte is available.
IAsyncResult BeginWrite(Byte[],Int32,Int32,AsyncCallback,Object)
Begins an asynchronous write operation. (Consider using Int32) instead.)
| Parameter | Description |
|---|---|
| buffer | The buffer to write data from. |
| offset | The byte offset in buffer from which to begin writing. |
| count | The maximum number of bytes to write. |
| callback | An optional asynchronous callback, to be called when the write is complete. |
| state | A user-provided object that distinguishes this particular asynchronous write request from other requests. |
Returns: An IAsyncResult that represents the asynchronous write, which could still be pending.
void EndWrite(IAsyncResult)
Ends an asynchronous write operation. (Consider using Int32) instead.)
| Parameter | Description |
|---|---|
| asyncResult | A reference to the outstanding asynchronous I/O request. |
void Write(Byte[],Int32,Int32)
When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.
| Parameter | Description |
|---|---|
| buffer | An array of bytes. This method copies count bytes from buffer to the current stream. |
| offset | The zero-based byte offset in buffer at which to begin copying bytes to the current stream. |
| count | The number of bytes to be written to the current stream. |
int Read(Byte[],Int32,Int32)
When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.
| Parameter | Description |
|---|---|
| buffer | An array of bytes. When this method returns, the buffer contains the specified byte array with the values between offset and (offset + count - 1) replaced by the bytes read from the current source. |
| offset | The zero-based byte offset in buffer at which to begin storing the data read from the current stream. |
| count | The maximum number of bytes to be read from the current stream. |
Returns: The total number of bytes read into the buffer. This can be less than the number of bytes requested if that many bytes are not currently available, or zero (0) if the end of the stream has been reached.
void Close
Closes the current stream and releases any resources (such as sockets and file handles) associated with the current stream. Instead of calling this method, ensure that the stream is properly disposed.