Is there a class for buffer storage? maybe like ArrayList?
Hi.
Say I'm building a ZIP file, the ZIP file has a header of UInt32 0x04034b50 then some 2-byte tags, short 0x0A00, and another short.
How can i save these:
uint part1=0x04034b50;
ushort part2=0x0a00;
ushort part3=0;
I can't put then into an ArrayList because they are of different type.
In the end I want to extract the arraylist and put into a byte[].
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
AnttiRank #9,295 · 208 pointsPosted Feb 19, 2006, 10:02 AM EST
You could write the values to the byte array using BinaryWriter and MemoryStream. First, create your byte array buffer with some good size. Then create MemoryStream object, and use your buffer as a constructor parameter. Then create BinaryWriter, and pass the memory stream to it.
Now You can write many sorts of information to the byte array buffer, with BinaryWriter's Write -methods.
byte[] buffer = new byte[256]; MemoryStream stream = new MemoryStream(buffer); BinaryWriter writer = new BinaryWriter(stream); writer.Write("somevalues");AnttiRank #9,295 · 208 pointsPosted Feb 21, 2006, 12:49 AM EST
1 short reply
Rob Jones7 pointsPosted Feb 20, 2006, 12:43 PM EST