Copy a memory stream into a byte array
Posted on 2005-03-09
Ok here is a very simple one, but I need an answer quick please.
I have a memory stream (tmemorystream) and I need to put the contents of the memory stream into a byte array.
Here is what i tried to do but I've obviously done something wrong as it doesnt work
TEncoded : String;
SomeStream : tmemorystream;
bufs : array of byte;
//SNIP unimportant code//
SomeStream := TMemoryStream.Create;
SomeStream := HTTPSend(Tencoded);
If I step through the code, I see that a byte array of 6 bytes is allocated (the same as the size of the tmemorystream) but the bytes are all 00's but the memorystream contains actual binary data
I'm sure I have just missed something simple
Thanks in advance for any help