469,266 Members | 1,679 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,266 developers. It's quick & easy.

byte array - writing it out to a file

I have an array of bytes which i want to write out to a
file.
What classes do i need that do this??

i know you can do stuff with binary writer and stream
writer, but how do i create a file with my data in it?
thanks...
Nov 17 '05 #1
3 69475
Biteme,

You mean this one?
//using System.IO;
using(BinaryWriter binWriter =
new BinaryWriter(File.Open(@"C:\Test2\Test.txt", FileMode.Create)))
{
byte[] bb = new byte[] {65,66,67};
binWriter.Write(bb);
}

I hope this helps,

Cor
Nov 17 '05 #2
thanks for that cor. its what i was looking for.

cheers.
-----Original Message-----
Biteme,

You mean this one?
//using System.IO;
using(BinaryWriter binWriter =
new BinaryWriter(File.Open(@"C:\Test2\Test.txt", FileMode.Create))){
byte[] bb = new byte[] {65,66,67};
binWriter.Write(bb);
}

I hope this helps,

Cor
.

Nov 17 '05 #3
biteme <an*******@discussions.microsoft.com> wrote:
I have an array of bytes which i want to write out to a
file.
What classes do i need that do this??

i know you can do stuff with binary writer and stream
writer, but how do i create a file with my data in it?
thanks...


Just use a FileStream - the MSDN docs for it have some examples.
Using a BinaryWriter when you just want to write out an array of bytes
is overkill - BinaryWriters are really for writing sequences of
primitives etc.

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

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Gigi | last post: by
2 posts views Thread by Sathyaish | last post: by
5 posts views Thread by news.microsoft.com | last post: by
2 posts views Thread by Chris | last post: by
11 posts views Thread by chaitali.pats | last post: by
10 posts views Thread by Scott Townsend | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.