Class StreamExtensions
Extensions for the Stream class.
Inherited Members
Namespace: TheXDS.MCART.Types.Extensions
Assembly: MCART.dll
Syntax
public static class StreamExtensions
Methods
| Edit this page View SourceDestroy(Stream)
Destroys the content of the Stream.
Declaration
public static void Destroy(this Stream fs)
Parameters
Type | Name | Description |
---|---|---|
Stream | fs | The Stream to destroy. |
Exceptions
Type | Condition |
---|---|
IOException | Thrown if an I/O error occurs during the operation. |
NotSupportedException | Thrown if the Stream does not support writing and seeking operations, such as when it's constructed from a pipe or console stream. |
ObjectDisposedException | Occurs when this operation is attempted on an already disposed Stream. |
ReadString(Stream, int)
Reads a string from the sequence and advances the read position past the last character read.
Declaration
public static string ReadString(this Stream fs, int count)
Parameters
Type | Name | Description |
---|---|---|
Stream | fs | The Stream to read the string from. |
int | count | Number of characters to read. |
Returns
Type | Description |
---|---|
string | The string that has been read. |
ReadString(Stream, int, Encoding)
Reads a string from the sequence and advances the read position past the last character read.
Declaration
public static string ReadString(this Stream fs, int count, Encoding encoding)
Parameters
Type | Name | Description |
---|---|---|
Stream | fs | The Stream to read the string from. |
int | count | Number of characters to read. |
Encoding | encoding | Encoding to use. |
Returns
Type | Description |
---|---|
string | The string that has been read. |
ReadStringAsync(Stream, int)
Asynchronously reads a string from the sequence and advances the read position past the last Unicode character read.
Declaration
public static Task<string> ReadStringAsync(this Stream fs, int count)
Parameters
Type | Name | Description |
---|---|---|
Stream | fs | The Stream to read the string from. |
int | count | Number of characters to read. |
Returns
Type | Description |
---|---|
Task<string> | The string that has been read. |
ReadStringAsync(Stream, int, Encoding)
Asynchronously reads a string from the sequence and advances the read position past the last character read.
Declaration
public static Task<string> ReadStringAsync(this Stream fs, int count, Encoding encoding)
Parameters
Type | Name | Description |
---|---|---|
Stream | fs | The Stream to read the string from. |
int | count | Number of characters to read. |
Encoding | encoding | Encoding to use. |
Returns
Type | Description |
---|---|
Task<string> | The string that has been read. |
ReadStringToAsync(Stream, long)
Asynchronously reads a string from the current position until reaching the specified position.
Declaration
public static Task<string> ReadStringToAsync(this Stream fs, long pos)
Parameters
Type | Name | Description |
---|---|---|
Stream | fs | The Stream to read the string from. |
long | pos | Position up to which the string will be read. |
Returns
Type | Description |
---|---|
Task<string> | The string that has been read. |
ReadStringToEndAsync(Stream)
Asynchronously reads a string from the current position until the end of the sequence.
Declaration
public static Task<string> ReadStringToEndAsync(this Stream fs)
Parameters
Type | Name | Description |
---|---|---|
Stream | fs | The Stream to read the string from. |
Returns
Type | Description |
---|---|
Task<string> | The string that has been read. |
RemainingBytes(Stream)
Gets the number of remaining bytes from the current position.
Declaration
public static long RemainingBytes(this Stream fs)
Parameters
Type | Name | Description |
---|---|---|
Stream | fs | The Stream to get the remaining bytes from. |
Returns
Type | Description |
---|---|
long | The number of remaining bytes from the current position. |
Skip(Stream, int)
Skips the specified number of bytes in the sequence from the current position.
Declaration
public static void Skip(this Stream fs, int bytesToSkip)
Parameters
Type | Name | Description |
---|---|---|
Stream | fs | The Stream where the read cursor will be skipped. |
int | bytesToSkip | Bytes to skip. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | Thrown if |
WriteBytes(Stream, params byte[])
Declaration
public static void WriteBytes(this Stream fs, params byte[] bytes)
Parameters
Type | Name | Description |
---|---|---|
Stream | fs | The Stream to write bytes on. |
byte[] | bytes |
WriteSeveralBytes(Stream, params byte[][])
Declaration
public static void WriteSeveralBytes(this Stream fs, params byte[][] bytes)
Parameters
Type | Name | Description |
---|---|---|
Stream | fs | The Stream to write bytes on. |
byte[][] | bytes |