Constructors: NewBinaryReader

NewBinaryReader

Returns a new BinaryReader that can read from the specified stream usind the specified encoding.



 Public Function NewBinaryReader(
	  ByVal InputStream As Stream,
	  Optional ByVal Encoding As Encoding,
	  Optional ByVal LeaveOpen As Boolean ) As BinaryReader

Parameters

InputStream
[ByVal] Stream. The stream to read the data from.
Encoding
[ByVal] Optional. Encoding. The encoding system to be used to decode the bytes from the stream.
LeaveOpen
[ByVal] Optional. Boolean. The stream can optionally be left open after the reader has been closed.

Return Values

BinaryReader -  The new BinaryReader with the specified stream and encoding.

Remarks

If Encoding is not specified, then the reader is created using UTF8Encoding.

Exceptions

ExceptionCondition
ArgumentNullExceptionInputStream is Nothing.
ArgumentExceptionThe stream does not support reading, or is already closed.

Examples

The following example demonstrates the two ways to create a BinaryReader object using the NewBinaryReader constructor method.

Public Sub Main()
    Dim Source As FileStream
    Dim Reader As BinaryReader
    
    Set Source = File.OpenFile("MyFile.txt", FileMode.OpenExisting)
    
    ' method one
    Set Reader = NewBinaryReader(Source)
    
    ' method two
    Set Reader = Cor.NewBinaryReader(Source)
    
End Sub

See Also

Project CorLib Overview

Class Constructors Overview