:) again with the binary streams and the strings and the memory blocks...

From the manual

Dim mb As New MemoryBlock(100)
Dim b As New BinaryStream(mb)
b.Write("Hello")
b.Close

Can the memory block size be set to zero such that b.Write methods grow the memory block.
Is it that the memory blocks grow in chunks not bytes?

is this the best way to transfer from file to memory block?

dim dbs, sbs as binaryStream
...
dbs.Write(sbs.Read(ItemLength))

I take it I can not write to a memory block until it has the memory allocated to receive the data…

You may want to look into
http://developer.xojo.com/xojo-core-mutablememoryblock

[quote=376217:@Brian O’Brien]Can the memory block size be set to zero such that b.Write methods grow the memory block.
Is it that the memory blocks grow in chunks not bytes?[/quote]

Yes. The MemoryBlock will automatically grow when you write to the BinaryStream. I use this technique frequently with the “classic” framework. The basic algorithm I’ve observed is that a zero-length MemoryBlock will be enlarged to at least 32 bytes on the first write, and then it is doubled in size every time you write past the end of the stream. In other words, BinaryStream.Length <= MemoryBlock.Size. When you Close the BinaryStream the extra bytes are truncated.

[code]is this the best way to transfer from file to memory block?

dim dbs, sbs as binaryStream

dbs.Write(sbs.Read(ItemLength))[/code]

In this specific example it’s not necessary since you’re just reading the whole file into memory in one operation. Using a BinaryStream to write memory is most useful when you have many separate writes rather than one big write.

Correct.