IIOStream.CopyFrom

Syntax

CopyFrom(SourceStream: IIOStream; Count: Integer);

Parameters

SourceStream. Source stream, from which it is required to copy.

Count. The amount of data in bytes, which are required to copy.

Description

The CopyFrom method copies data from the specified stream to the current stream.

Comments

The amount of data to be copied is specified by means of the Count parameter. If the "-1" or "0" value is specified, all stream data is copied.

If the current stream is a file one, all its contents is rewritten on copying.

If the current stream is implemented in computer memory, data is added to the end of the stream on copying.

Example

Sub UserProc;
Var
    File1, File2: IFileInfo;
    BinR: IBinaryReader;
    BinW: IBinaryWriter;
    Stream: IIOStream;
Begin
    File1 := New FileInfo.Attach("c:\1.dat");
    File2 := New FileInfo.Attach("c:\2.dat");
    If File1.Exists Then
        BinR := File1.OpenBinaryReader;
        BinW := File2.OpenBinaryWriter(True);
        Stream := BinW.Stream;
        Stream.CopyFrom(BinR.Stream, BinR.Stream.Size);
    End If;
    Dispose File1;
    Dispose File2;
End Sub UserProc;

After executing the example the 2.dat file is created and contents of the 1.dat file is copied into it.

See also:

IIOStream