|
|
System.IO.BinaryWriter Class |
|
|
Description | |
|
This class is used to write primitive data in binary (rather than character) format to a stream. This stream is often targetted at a file, as in the examples.
The Write method provides good flexibility, allowing a range of primitive types, including strings to be written to the stream, with conversion to byte format where appropriate. For example, a Boolean true value gets stored in a whole byte with value of 1.
When reading from a Binary file, it is crucial that the formatting of data used by BinaryWriter be accurately recognised. Being 1 byte out of sequence can completely destroy the sequencing of the remaining file contents.
|
|
Syntax | |
|
Constructor Create ; | Constructor Create ( |
DataStream : Stream ); | Constructor Create ( |
DataStream : Stream; TextEncoding : System.Text.Encoding ); |
|
Methods | |
|
| Close | Closes the BinaryWriter |
| Seek | Seek to a specified offset from the start, current, or end stream position |
| Write | Write a primitive data element to the stream |
|
|
|
Fields | |
|
Null | | BinaryWriter | | Specifies a BinaryWriter with no backing store. |
|
Properties | |
|
BaseStream | | BinaryWriter | | Gets the underlying stream of the BinaryWriter. |
|
Microsoft MSDN links | |
|
|
|
|
|
|