Class StreamExtensions
Extension methods for Stream class.
Inherited Members
Namespace: UnityFx.Async.Extensions
Assembly: UnityFx.Async-netstandard2.0.dll
Syntax
public static class StreamExtensions
Methods
| Improve this Doc View SourceReadAsync(Stream, Byte[], Int32, Int32)
Asynchronously reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.
Declaration
public static IAsyncOperation<int> ReadAsync(this Stream stream, byte[] buffer, int offset, int count)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read data from. |
System.Byte[] | buffer | The buffer to write the data into. |
Int32 | offset | The byte offset in |
Int32 | count | The maximum number of bytes to read. |
Returns
Type | Description |
---|---|
IAsyncOperation<Int32> | An IAsyncOperation<TResult> that represents the asynchronous read operation. The value of the result parameter contains the total number of bytes read into the buffer. The result value can be less than the number of bytes requested if the number of bytes currently available is less than the requested number, or it can be 0 (zero) if the end of the stream has been reached. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if |
ArgumentOutOfRangeException | Thrown if |
ArgumentException | Thrown if the sum of |
NotSupportedException | Thrown if the stream does not support reading. |
InvalidOperationException | Thrown if the stream is currently in use by a previous read operation. |
ObjectDisposedException | Thrown if the stream has been disposed. |
WriteAsync(Stream, Byte[], Int32, Int32)
Asynchronously writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.
Declaration
public static IAsyncOperation WriteAsync(this Stream stream, byte[] buffer, int offset, int count)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to write data to. |
System.Byte[] | buffer | The buffer to write data from. |
Int32 | offset | The zero-based byte offset in |
Int32 | count | The maximum number of bytes to write. |
Returns
Type | Description |
---|---|
IAsyncOperation | An IAsyncOperation that represents the asynchronous write operation. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if |
ArgumentOutOfRangeException | Thrown if |
ArgumentException | Thrown if the sum of |
NotSupportedException | Thrown if the stream does not support writing. |
InvalidOperationException | Thrown if the stream is currently in use by a previous write operation. |
ObjectDisposedException | Thrown if the stream has been disposed. |