StreamReader Constructor (Stream)

Initializes a new instance of the StreamReader class for the specified stream.

Namespace:  System.IO
Assembly:  mscorlib (in mscorlib.dll)

public StreamReader(
	Stream stream
)

Parameters

stream
Type: System.IO.Stream
The stream to be read.

ExceptionCondition
ArgumentException

stream does not support reading.

ArgumentNullException

stream is null.

This constructor initializes the encoding to UTF8Encoding, the BaseStream property using the stream parameter, and the internal buffer to the default size.

The StreamReader object calls Stream.Dispose() on the provided Stream object when StreamReader.Dispose is called.

Caution noteCaution:

When you compile a set of characters with a particular cultural setting and retrieve those same characters with a different cultural setting, the characters might not be interpretable, and could cause an exception to be thrown.

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2015 Microsoft