How to copy files in Free Pascal

To copy files in Free Pascal, you can do it in many ways, one of them is to use TStreamFile‘s CopyFrom method.

This example could copy any type of files without changing it’s contents. But destination file information will be changed, like file name, and updated time.

  SourceF, DestF: TFileStream;
  ‪SourceF:= TFileStream.Create('Photo.jpg', fmOpenRead);
  ‪DestF:= TFileStream.Create('PhotoCopy.jpg', fmCreate);
  ‪DestF.CopyFrom(SourceF, SourceF.Size);

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s