Arne <(E-Mail Removed)> wrote:
> The Binarywriter appends an extra carriage return at the end. Is there a way
> to supress that?
>
> string file = @"c:\temp\binary.txt";
> FileStream fs= new FileStream(file,
> FileMode.Create, FileAccess.Write, FileShare.None);
> BinaryWriter bw = new BinaryWriter(fs);
> bw.Write("BINARY PLEASE");
> bw.Flush();
> bw.Close();
It's not putting a carriage return at the end, it's putting a byte 13
at the *start* of the stream, just as described by
BinaryWriter.Write(string) - it's the length prefix for the string
data, basically.
Here's a dump of the file written by the above code:
00000000 0D 42 49 4E 41 52 59 20 50 4C 45 41 53 45 .BINARY PLEASE
--
Jon Skeet - <(E-Mail Removed)>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too