PC Review


Reply
Thread Tools Rate Thread

byte array - writing it out to a file

 
 
biteme
Guest
Posts: n/a
 
      23rd Mar 2005
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...
 
Reply With Quote
 
 
 
 
Cor Ligthert
Guest
Posts: n/a
 
      23rd Mar 2005
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


 
Reply With Quote
 
biteme
Guest
Posts: n/a
 
      23rd Mar 2005
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
>
>
>.
>

 
Reply With Quote
 
Jon Skeet [C# MVP]
Guest
Posts: n/a
 
      23rd Mar 2005
biteme <(E-Mail Removed)> 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 - <(E-Mail Removed)>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Writing Byte Array to Disk Garth Wells Microsoft C# .NET 11 3rd Oct 2007 03:37 AM
Only writing 1 byte to a file stream on one pc in office Claire Microsoft C# .NET 3 23rd Jul 2007 06:21 PM
Writing a byte to a specific location in a file =?Utf-8?B?Q3JhaWc=?= Microsoft VB .NET 2 16th Jun 2006 11:58 PM
Writing Byte to file, how can i start new line =?Utf-8?B?R2lkaQ==?= Microsoft C# .NET 4 31st Oct 2005 07:03 AM
Reading/Writing Byte Array for UDP comms Zahid Microsoft Dot NET Compact Framework 0 2nd Dec 2003 03:04 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:46 PM.