On Feb 27, 2006, at 9:29 AM, Harrie Westphal wrote:

Is there a way to read a BinaryStream into a MemoryBlock other than byte by byte as in the following? This is the only method of doing so that I could get to work. Sure seems like there should be some way to use the Read(x) method to read the entire file in at once but if there is, how to do it has eluded me so far.

j = theFile.Length
n = j - 1
mb = New MemoryBlock(j)
For i = 0 to n
mb.Byte(i) = b.ReadByte
Next i

There are several ways.

You can read an arbitrary size with the MemoryBlock.StringValue() and BinaryStream.Read().

You can also assign a string like this:

    Dim mb As MemoryBlock = b.Read(b.Length)    // b is a BinaryStream

This is because there is an automatic conversion between string and MemoryBlock (REALbasic 5.5 and higher), so a MemoryBlock will be created to match exactly the same size and data as the string.

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to