MorkaLork Development

Interesting stuff I've picked up over the years...

Input/Output 14: BinaryWriter

2009-04-17 07:19:17 | 286 views | csharp class method tutorial binary writer binarywriter

The Basics

The BinaryWriter class is used to write binary data to a stream. You can construct a BinaryWriter object by passing a Stream object; you can�t pass a file path to create a BinaryWriter object. In addition, there is also a parameterless constructor. The BinaryWriter class� most important method is Write. This method has 18 overloads that guarantee that you can write any type of data to a BinaryWriter object. For example, the following code creates a BinaryWriter object that is linked to a new file called MyBinary.bin, and writes a byte and a string:

BinaryWriter bw = new BinaryWriter(File.Create("
Byte b = 17;
string s = "August";

Article comments

Feel free to comment this article using a facebook profile.

I'm using facebook accounts for identification since even akismet couldn't handle all the spam I receive every day.