473,473 Members | 2,008 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 69645
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.