Show / Hide Table of Contents

Class StreamExtensions

Extensions for the Stream class.

Inheritance
object
StreamExtensions
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: TheXDS.MCART.Types.Extensions
Assembly: MCART.dll
Syntax
public static class StreamExtensions

Methods

| Edit this page View Source

Destroy(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.

| Edit this page View Source

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.

| Edit this page View Source

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.

| Edit this page View Source

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.

| Edit this page View Source

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.

| Edit this page View Source

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.

| Edit this page View Source

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.

| Edit this page View Source

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.

| Edit this page View Source

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 bytesToSkip is less than zero, or if skipping extends the cursor beyond the sequence.

| Edit this page View Source

WriteBytes(Stream, params byte[])

Writes a set of byte to the Stream.

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

Collection of byte to write in the Stream.

| Edit this page View Source

WriteSeveralBytes(Stream, params byte[][])

Writes a set of sequences of byte to the Stream.

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

Collections of byte to write in the Stream.

  • Edit this page
  • View Source
In this article
Back to top Generated by DocFX