Constructors: NewStreamReader

NewStreamReader

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



 Public Function NewStreamReader(
	  ByVal Source As Variant,
	  Optional ByVal Encoding As Encoding,
	  Optional ByVal determineEncodingFromByteOrderMarks As Boolean = True,
	  Optional ByVal BufferSize As Long = 4096 ) As StreamReader

Parameters

Source
[ByVal] Variant. A FileName 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: 4096

Return Values

StreamReader -  A newly initialized StreamReader object.

Remarks

If a filename 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.
&HFE, &HFF - UnicodeEncoding with Little Endian byte ordering
&HFF, &HFE - UnicodeEncoding with Big Endian byte ordering
&HEF, &HBB, &HBF - UTF8Encoding
If no encoding is identified, then Encoding.UTF8 is used.

See Also

Project VBCorLib Overview Class Constructors Overview Constructors Properties Constructors Methods NewStack NewStreamWriter