Dumping a memoryblock to a binary file

Hi all,

Sorry for a very lame question, but I’m just having a mental block on this one. In the good old bad old RB days I could dump a memoryblock to a binaryfile with something as simple as:

b1.write mb

where b1 is a binarystream and mb is a memoryblock. But with the newer Xojo.Core.MutableMemoryBlock class,
I’ve been reduced to the glacial:

z=mb.size-2
for x=0 to z step 2
b1.WriteUInt16 mb.UInt16Value(x)
next

(And linus torvalds rightly had some pretty sharp things to say about folks who write to files byte by byte)

I was expecting to be able to at least do something like:

b1.Write mb.left(mb.length)

but this gives me unexpected compilation errors. Could someone put me out of my misery here?

Are you using the classic BinaryStream? Xojo.IO.BinaryStream.Write takes a new MemoryBlock.

Yes - you’re right. I’ll swap to the newer class. Thanks!