byte array - writing it out to a file

  • Thread starter Thread starter biteme
  • Start date Start date
B

biteme

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...
 
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
 
biteme said:
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.
 
Back
Top