Method ReadAsStringAsync
ReadAsStringAsync(Stream)
Reads the contents of stream from it's current point to the end and returns the result as a string.
Declaration
public static Task<string> ReadAsStringAsync(this Stream stream)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | The stream to read from. |
Returns
Type | Description |
---|---|
Task<System.String> | A System.Threading.Tasks.Task whose result is the string representation of the stream contents. |
Remarks
This overload uses the System.Text.UTF8Encoding to convert the stream contents into a string.
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown if |
System.InvalidOperationException | Thrown if the stream length is greater than System.Int32.MaxValue. |
ReadAsStringAsync(Stream, Encoding)
Reads the contents of stream from it's current point to the end and returns the result as a string.
Declaration
public static Task<string> ReadAsStringAsync(Stream stream, Encoding encoding)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
Encoding | encoding | The text encoding to use when decoding the stream into a string. |
Returns
Type | Description |
---|---|
Task<System.String> | A System.Threading.Tasks.Task whose result is the string representation of the stream contents. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown if |
System.InvalidOperationException | Thrown if the stream length is greater than System.Int32.MaxValue. |