NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

StreamReader Constructor (Stream, Encoding, Int32, Boolean)

Creates a new StreamReader for the given stream, with the specified character encoding and buffer size. This constructor automatically detects UTF-8, little endian Unicode, and big endian Unicode text.

[Visual Basic]
Overloads Public Sub New( _
   ByVal stream As Stream, _
   ByVal encoding As Encoding, _
   ByVal bufferSize As Integer, _
   ByVal detectEncodingFromByteOrderMarks As Boolean _
)
[C#]
public StreamReader(
   Stream stream,
   Encoding encoding,
   int bufferSize,
   bool detectEncodingFromByteOrderMarks
);
[C++]
public: StreamReader(
   Stream* stream,
   Encoding* encoding,
   int bufferSize,
   bool detectEncodingFromByteOrderMarks
);
[JScript]
public function StreamReader(
   stream : Stream,
   encoding : Encoding,
   bufferSize : int,
   detectEncodingFromByteOrderMarks : Boolean
);

Parameters

stream
The stream to be read.
encoding
The character encoding to use.
bufferSize
The suggested minimum buffer size.
detectEncodingFromByteOrderMarks
An indicator of the encoding type.

Exceptions

Exception Type Condition
ArgumentException The stream does not support reading.
ArgumentNullException stream or encoding is a null reference (in Visual Basic Nothing).
ArgumentOutOfRangeException bufferSize is negative.

Remarks

This constructor allows you to change the encoding the first time you read from the StreamReader. The detectEncodingFromByteOrderMarks parameter detects the encoding by looking at the first three bytes of the stream. It automatically recognizes UTF-8, little endian Unicode, and big endian Unicode text. If none of those three match, the user-provided Encoding is used.

See Also

StreamReader Class | StreamReader Members | System.IO Namespace | StreamReader Constructor Overload List