Copy a file

{
The CopyFile function copies an existing file to a new file.

CopyFile(
lpExistingFileName : PChar, // name of an existing file
lpNewFileName : PChar,      // name of new file
bFailIfExists : Boolean);   // operation if file exists

bFailIfExists:
Specifies how this operation is to proceed if a file of the same name as
that specified by lpNewFileName already exists.
If this parameter is TRUE and the new file already exists, the function fails.
If this parameter is FALSE and the new file already exists,
the function overwrites the existing file and succeeds.
}

var
fileSource, fileDest: string;
begin
fileSource := ‘C:SourceFile.txt’;
fileDest := ‘G:DestFile.txt’;
CopyFile(PChar(fileSource), PChar(fileDest), False);
end;

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.