Go4Expert (http://www.go4expert.com/)
-   C# (http://www.go4expert.com/forums/c-sharp/)
-   -   writing byte (http://www.go4expert.com/forums/writing-byte-t736/)

TinyClone 17Apr2006 19:56

writing byte
Im trying to write some come but it isnt coming along. This is what i have/want:

int[] myIntArray
int[] myintArray2
Bitmap myBitmap
// All of these have some value(s)
// I want to write them to a file using this protocol (byte sizes are fixed):
(4 bytes) Size of myIntArray
(4 bytes) Position of myIntArray in the file
(4 bytes) Size of myIntArray2
(4 bytes) Position of myIntArray2 in the file
(4 bytes) Size of myBitmap
(4 bytes) Position of myBitmap in the file
(lots of bytes, 4 per element) myIntArray
(lots of bytes, 4 per element) myIntArray2
(lots of bytes, preferably PNG fromat) myBitmap

I'd really apreciate any help

coderzone 17Apr2006 21:33

Re: writing byte
Actually I could not understand what you are looking for.

TinyClone 17Apr2006 23:11

Re: writing byte

I looking for code, to write variables to a file, in the way descripbed above

coderzone 18Apr2006 06:57

Re: writing byte
BinaryWriter will do the job for you.

Here is a simple sample
Code: C#

FileStream  fs = File.Create(Server.MapPath("test.bin"));
BinaryWriter bw = new BinaryWriter(fs);

int i = 10;


All times are GMT +5.5. The time now is 01:13.