Mono Class Library: System.IO.StreamReader Overview | Members

System.IO.StreamReader Constructor

Constructs and initializes a new instance of the System.IO.StreamReader class for the specified stream, with the specified byte order mark detection option. [Edit]

public StreamReader (Stream stream, bool detectEncodingFromByteOrderMarks)

Parameters

stream
The stream to read. [Edit]
detectEncodingFromByteOrderMarks
A bool value that indicates whether the new System.IO.StreamReader is required to look for byte order marks at the beginning of the stream. Specify true to enable detection of byte order marks; otherwise, specify false . [Edit]

Exceptions

TypeReason
ArgumentExceptionstream does not support reading. [Edit]
ArgumentNullExceptionstream is null. [Edit]

Remarks

This constructor initializes the StreamReader.CurrentEncoding property to System.Text.UTF8Encoding , the StreamReader.BaseStream property using stream , and the internal buffer to the default size.

Note: The default buffer size is implementation defined.

If requested, the current constructor detects the encoding by examining the first three bytes of the stream. The constructor automatically recognizes UTF-8, little-endian Unicode, and big-endian Unicode text if the file starts with the appropriate byte order marks. Otherwise, UTF-8 encoding is used. For more information, see the System.Text.Encoding.GetPreamble method.

[Edit]

Requirements

Namespace: System.IO
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0