Arne <(E-Mail Removed)> wrote:
> The streamwriter appends an extra carriage return at the end. Is there a way
> to supress that?
>
> file = @"c:\temp\text.txt";
> fs = new FileStream(file,
> FileMode.Create, FileAccess.Write, FileShare.None);
> StreamWriter sw = new StreamWriter(fs);
> sw.Write("BINARY PLEASE");
> sw.Flush();
> sw.Close();
The above code doesn't write a carriage return. Try running the
following program (containing your code, modified for my directory
structure):
using System;
using System.IO;
class Test
{
static void Main()
{
string file = @"c:\test\text.txt";
FileStream fs = new FileStream(file,
FileMode.Create, FileAccess.Write,
FileShare.None);
StreamWriter sw = new StreamWriter(fs);
sw.Write("BINARY PLEASE");
sw.Flush();
sw.Close();
}
}
The file length afterwards is 13 bytes, which doesn't leave any room
for carriage returns, if you count the characters in the string...
--
Jon Skeet - <(E-Mail Removed)>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too