• Home
  • API Documentation
Show / Hide Table of Contents
  • McStreamy
    • ByteArrayExtensions
      • ToStream
    • NonClosingStreamAdapter
      • CanRead
      • CanSeek
      • CanTimeout
      • CanWrite
      • Dispose
      • Flush
      • Length
      • NonClosingStreamAdapter
      • Position
      • Read
      • ReadByte
      • ReadTimeout
      • Seek
      • SetLength
      • ToString
      • Write
      • WriteByte
      • WriteTimeout
    • StreamExtensions
      • ReadAllBytes
      • ReadAllBytesAsync
      • ReadAsString
      • ReadAsStringAsync
      • WriteAllBytes
      • WriteAllBytesAsync
    • StringExtensions
      • ToStream

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 stream is null.

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 stream or encoding is null.

System.InvalidOperationException

Thrown if the stream length is greater than System.Int32.MaxValue.

Back to top Copyright (c) 2017 Troy Willmot