StreamReader Constructor (Stream)

StreamReader Constructor (Stream)


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

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

new : 
        stream:Stream -> StreamReader


Type: System.IO.Stream

The stream to be read.

Exception Condition

stream does not support reading.


stream is null.

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

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


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.

For a list of common I/O tasks, see Common I/O Tasks.

The following code example demonstrates this StreamReader constructor.

No code example is currently available or this language may not be supported.

Universal Windows Platform
Available since 4.5
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top
© 2015 Microsoft