472,356 Members | 487 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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 69583
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Gigi | last post by:
Hello, I have a byte array and i must send(to blocks) to remote class In the remote class i write a file stream...... How? In my sample i send stream...
2
by: Sathyaish | last post by:
I am using MCI (winmm.dll) to read, record and playback sound. For now, I am doing this with disk files instead of realtime doing it straight from the memory. If I want to stream/relay/transmit...
3
by: Nick | last post by:
I have found a class that compresses and uncompresses data but need some help with how to use part of it below is the deflate method which compresses the string that I pass in, this works OK. At...
2
by: Dunc | last post by:
Hi, I've got an HttpWebResponse object, all working fine. I'm getting the underlying stream and currently writing it to a file using the ReadToEnd() method. All happy. I want to do a bit of...
5
by: news.microsoft.com | last post by:
Hello, what is the most performant size for the byte array for reading/writing using 2 filestreams? example code: Dim bytearrayinput(4095) As Byte Dim rdlen As Long = 0 Dim totlen As Long...
2
by: Chris | last post by:
How do I save an array of bytes to a file? I am binding a update parameter to a fileupload control. It passes the file to my object as a Filebytes datatype. I am assuming it is just an array of...
11
by: chaitali.pats | last post by:
Hi , I have implemented MD5 in C language . I am getting an output of 32 bits Hexadecimal number . for example : 83a80d3ca057492f0ce99ac1db8dced0 I need to convert this string same to 16...
1
by: | last post by:
Hi all, I am writing a sendmail milter application in Java. The incoming mails will usually have image file as attachments. My application is currently able to extract the ImageFile and save it...
10
by: Scott Townsend | last post by:
So I need to talk to a devices that expects all of the bits and bytes I sent it to be in specific places (not yet 100% defined). I wanted to create a structure/class with all of the data in it...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
0
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...

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.