Skip to main content
.NET Framework Class Library
BinaryReader Constructor (Stream, Encoding, Boolean)

Initializes a new instance of the BinaryReader class based on the specified stream and character encoding, and optionally leaves the stream open.

Namespace:   System.IO
Assembly:  mscorlib (in mscorlib.dll)
Syntax
Public Sub New ( _
	input As [%$TOPIC/gg712804_en-us_VS_110_2_0_0_0_0%], _
	encoding As [%$TOPIC/gg712804_en-us_VS_110_2_0_0_0_1%], _
	leaveOpen As [%$TOPIC/gg712804_en-us_VS_110_2_0_0_0_2%] _
)
public BinaryReader(
	[%$TOPIC/gg712804_en-us_VS_110_2_0_1_0_0%] input,
	[%$TOPIC/gg712804_en-us_VS_110_2_0_1_0_1%] encoding,
	[%$TOPIC/gg712804_en-us_VS_110_2_0_1_0_2%] leaveOpen
)
public:
BinaryReader(
	[%$TOPIC/gg712804_en-us_VS_110_2_0_2_0_0%]^ input, 
	[%$TOPIC/gg712804_en-us_VS_110_2_0_2_0_1%]^ encoding, 
	[%$TOPIC/gg712804_en-us_VS_110_2_0_2_0_2%] leaveOpen
)
new : 
        input:[%$TOPIC/gg712804_en-us_VS_110_2_0_3_0_0%] * 
        encoding:[%$TOPIC/gg712804_en-us_VS_110_2_0_3_0_1%] * 
        leaveOpen:[%$TOPIC/gg712804_en-us_VS_110_2_0_3_0_2%] -> BinaryReader

Parameters

input
Type: System.IOStream

The input stream.

encoding
Type: System.TextEncoding

The character encoding to use.

leaveOpen
Type: SystemBoolean

true to leave the stream open after the BinaryReader object is disposed; otherwise, false.

Exceptions
ExceptionCondition
ArgumentException

The stream does not support reading, is , or is already closed.

ArgumentNullException

encoding or input is .

Version Information

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5

.NET for Windows Store apps

Supported in: Windows 8

.NET for Windows Phone apps

Supported in: Windows Phone 8.1, Windows Phone 8, Silverlight 8.1
Platforms

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.