System.IO.BinaryWriter Class

Writes primitive types in binary to a stream and supports writing strings in a specific encoding.

See Also: BinaryWriter Members

Syntax

[System.Runtime.InteropServices.ComVisible(true)]
public class BinaryWriter : IDisposable

Remarks

The System.IO.BinaryWriter class provides methods that simplify writing primitive data types to a stream. For example, you can use the BinaryWriter.Write(bool) method to write a Boolean value to the stream as a one-byte value. The class includes write methods that support different data types.

When you create a new instance of the System.IO.BinaryWriter class, you provide the stream to write to, and optionally specify the type of encoding and whether to leave the stream open after disposing the System.IO.BinaryWriter object. If you do not specify an encoding type, UTF-8 is used.

A derived class can override the methods of this class to give unique character encodings.

Requirements

Namespace: System.IO
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0