Writing Byte to file, how can i start new line

G

Guest

Hi,

i have a byte array, and i'm writing it to a file, i want to start a new
line, how can i do it? (like WriteLine in StreamWriter)

I'm using FileStream:
FileStream fs = new FileStream(file_name,FileMode.Create );

Aftrer i used fs.Write(Byte[] b1);
i want to start a new line in my file and then write my second array Byte[]
b2.

how can i do it?

Thanks,
Gidi.
 
D

Daniel O'Connell [C# MVP]

Gidi said:
Hi,

i have a byte array, and i'm writing it to a file, i want to start a new
line, how can i do it? (like WriteLine in StreamWriter)

I'm using FileStream:
FileStream fs = new FileStream(file_name,FileMode.Create );

Aftrer i used fs.Write(Byte[] b1);
i want to start a new line in my file and then write my second array
Byte[]
b2.

how can i do it?

Well, how do you define a new line? Is this a text file(and would using
StreamWriter be abetter option?) or is it a binary file? the characters '\n'
and '\r' are the usual newline characters but without knowing the encoding
its impossible to tell you exactly what to do.
 
L

Lebesgue

Bytes 10 and 13 are usually new line and carriage return, so try writing
these to start new line
 
J

Jon Skeet [C# MVP]

Gidi said:
i have a byte array, and i'm writing it to a file, i want to start a new
line, how can i do it? (like WriteLine in StreamWriter)

I'm using FileStream:
FileStream fs = new FileStream(file_name,FileMode.Create );

Aftrer i used fs.Write(Byte[] b1);
i want to start a new line in my file and then write my second array Byte[]
b2.

how can i do it?

Binary files don't *have* lines - they're just sequences of bytes.
What's going to read this, and what's it expecting?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top