Constructors: NewStreamReader

NewStreamReader

Creates a new StreamReader from either a FileName or an existing stream to read from.



 Public Function NewStreamReader(
	  ByRef Source As Variant,
	  Optional ByVal Encoding As Encoding,
	  Optional ByVal DetermineEncodingFromByteOrderMarks As Boolean = True,
	  Optional ByVal BufferSize As Long = 1024,
	  Optional ByVal LeaveOpen As Boolean ) As StreamReader

Parameters

Source
[ByRef] Variant. A file name used to open an existing file as a FileStream, or an existing Stream object.
Encoding
[ByVal] Optional. Encoding. The encoding to be used when decoding bytes from the stream.
DetermineEncodingFromByteOrderMarks
[ByVal] Optional. Boolean. Requests that the reader attempt to determine what type of encoding is being used in the stream by reading the first few bytes.  

Default: True

BufferSize
[ByVal] Optional. Long. The size of the internal cache used to improve performance.  

Default: 1024

LeaveOpen
[ByVal] Optional. Boolean. A boolean flag indicating if the underlying stream is to be left open once the StreamReader instance has closed.

Return Values

StreamReader -  A newly initialized StreamReader object.

Remarks

If a file name is specified, then an internal FileStream object is created using an initialization of Cor.NewFileStream(Source, FileMode.OpenExisting, FileAccess.ReadAccess, FileShare.ReadShare).

If DetermineEncodingFromByteOrderMarks is True, then up to 3 bytes are read from the stream upon the first attempt to read any data from the stream. The bytes are used to determine if a specific encoding has been used. There are 3 encoding signatures that are looked for.
BOMEncoding
&HFE, &HFFUnicodeEncoding with little-endian byte ordering is used.
&HFF, &HFEUnicodeEncoding with big-endian byte ordering is used.
&HEF, &HBB, &HBFUTF8Encoding is used.
If no encoding is identified, then Encoding.UTF8 is used.

See Also

Project CorLib Overview

Class Constructors Overview