473,327 Members | 2,012 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Writing Byte to file, how can i start new line

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.
Nov 17 '05 #1
4 16879

"Gidi" <sh*****@hotmail.com.dontspam> wrote in message
news:6D**********************************@microsof t.com...
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.
Nov 17 '05 #2
Bytes 10 and 13 are usually new line and carriage return, so try writing
these to start new line

"Gidi" <sh*****@hotmail.com.dontspam> wrote in message
news:6D**********************************@microsof t.com...
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.

Nov 17 '05 #3
Hi Gidi,
by using the newline property
http://www.kleinurl.de/?5sthfrw0
then you can substring it to every single byte
http://www.kleinurl.de/?5fevdnxx
and convert them to byte
http://www.kleinurl.de/?6bpqyu88
and at last write these bytes.

greetings from germany

chris

Nov 17 '05 #4
Gidi <sh*****@hotmail.com.dontspam> wrote:
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?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Nov 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Kristian Nybo | last post by:
Hi, I'm writing a simple image file exporter as part of a school project. To implement my image format of choice I need to work with big-endian bytes, where 'byte' of course means '8 bits', not...
2
by: melanieab | last post by:
Hi, I'm trying to store all of my data into one file (there're about 140 things to keep track of). I have no problem reading a specific string from the array file, but I wasn't sure how to...
1
by: mortenf | last post by:
I am in need of a method of writing a byte sequence to a file opened in text mode without translating <lf> ('\n') to <cr><lf> when compiling for MSDOS platform. Is there a way of skipping this...
2
by: Craig | last post by:
I have the need to write a byte of information to a specific location in a text file. eg. the file looks something like this. FYYNN Line 1 Line 2 <eof>
6
by: bonk | last post by:
I am trying to create a stream that writes text to a file and: - automatically creates a new file once the current file exceeds a certain size - makes it possible to be used by multiple threads...
0
by: lovecarole | last post by:
hi, i am the student who should write a program about reading wav file and do the DFT. actually i don't know how to read data of the wav song and save it into the array... if i want to read...
5
by: montyphyton | last post by:
as i understand there are two ways to write data to a file: using f.write("foo") and print >>f, "foo". what i want to know is which one is faster (if there is any difference in speed) since i'm...
6
by: John | last post by:
Hi I am trying to save settings of controls on my form to a file so I can read them back later and recreate the controls on the form. I have figured out how to go through all controls and get...
7
by: tshad | last post by:
I have a program in 2005 that is reading a text file removing text and then writing it back out again. It removes lines that start with PRINT. This program has worked fine for months. Now all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.