RAD Studio VCL Reference
TMemoryStream.Write Method

Writes Count bytes from Buffer to the current position in the memory buffer and updates the current position by Count bytes.

function Write(const Buffer; Count: Longint): Longint; override;
virtual __fastcall Longint Write(const  Buffer, Longint Count);

Use Write to insert Count bytes into the memory buffer of the memory stream, starting at the current position. Write will increase the size of the memory buffer, if necessary, to accommodate the data being written in. If the current position is not the end of the memory buffer, Write will overwrite the data following the current position. 

Write updates the Size property to Position + Count, and sets the Position property to the new value of Size. Thus, any data that was stored in the memory stream in the Count bytes after the current position is lost when calling Write. 

Write always writes the Count bytes in the Buffer, unless there is a memory failure. Thus, for TMemoryStream, Write is equivalent to the WriteBuffer method. 

All other data-writing methods of a memory stream (WriteBuffer, WriteComponent) call Write to do the actual writing. 


Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!