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

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

Namespace:   System.IO
Assemblies:   System.IO (in System.IO.dll)
  mscorlib (in mscorlib.dll)
Syntax
Public Sub New ( _
	output As [%$TOPIC/gg712841_en-us_VS_110_2_0_0_0_0%], _
	encoding As [%$TOPIC/gg712841_en-us_VS_110_2_0_0_0_1%], _
	leaveOpen As [%$TOPIC/gg712841_en-us_VS_110_2_0_0_0_2%] _
)
public BinaryWriter(
	[%$TOPIC/gg712841_en-us_VS_110_2_0_1_0_0%] output,
	[%$TOPIC/gg712841_en-us_VS_110_2_0_1_0_1%] encoding,
	[%$TOPIC/gg712841_en-us_VS_110_2_0_1_0_2%] leaveOpen
)
public:
BinaryWriter(
	[%$TOPIC/gg712841_en-us_VS_110_2_0_2_0_0%]^ output, 
	[%$TOPIC/gg712841_en-us_VS_110_2_0_2_0_1%]^ encoding, 
	[%$TOPIC/gg712841_en-us_VS_110_2_0_2_0_2%] leaveOpen
)
new : 
        output:[%$TOPIC/gg712841_en-us_VS_110_2_0_3_0_0%] * 
        encoding:[%$TOPIC/gg712841_en-us_VS_110_2_0_3_0_1%] * 
        leaveOpen:[%$TOPIC/gg712841_en-us_VS_110_2_0_3_0_2%] -> BinaryWriter
public function [%$TOPIC/gg712841_en-us_VS_110_2_0_4_0_0%](
	output : [%$TOPIC/gg712841_en-us_VS_110_2_0_4_0_1%], 
	encoding : [%$TOPIC/gg712841_en-us_VS_110_2_0_4_0_2%], 
	leaveOpen : [%$TOPIC/gg712841_en-us_VS_110_2_0_4_0_3%]
)

Parameters

output
Type: System.IOStream

The output stream.

encoding
Type: System.TextEncoding

The character encoding to use.

leaveOpen
Type: SystemBoolean

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

Exceptions
ExceptionCondition
ArgumentException

The stream does not support writing or is already closed.

ArgumentNullException

output or encoding is .

Version Information

.NET Framework

Supported in: 4.6, 4.5

Supported in: Windows Phone 8.1

Supported in: Windows Phone Silverlight 8.1

Supported in: Windows Phone Silverlight 8