From RAD Studio API Documentation
Jump to: navigation, search


function CopyFrom(const Source: TStream; Count: Int64 = 0; BufferSize: Integer = $100000): Int64;


__int64 __fastcall CopyFrom(TStream* const Source, __int64 Count = 0LL, int BufferSize = 0x100000);


Type Visibility Source Unit Parent
function public
System.Classes TStream


Copies a specified number of bytes from one stream to another.

Use CopyFrom to copy data from one stream to a different one. Using CopyFrom eliminates the need to create, read into, write from, and free a buffer when copying data.

CopyFrom copies Count bytes from the stream specified by Source into the stream. It then moves the current position by Count bytes and returns the number of bytes copied.

If Count is 0, CopyFrom sets Source position to 0 before reading and then copies the entire contents of Source into the stream. If Count is greater than or less than 0, CopyFrom reads from the current position in Source.

Because the CopyFrom method uses ReadBuffer and WriteBuffer to do the effective copying, if the Count is greater than the SourceStream size, ReadBuffer throws an exception stating that a stream read error has occured.

See Also

Code Examples