Skip to content

Flow documentation · legacy product

FileCon.CopyFile ​

Declaration ​

function CopyFile (const aDestPath, aDestName: string): boolean;

Example ​

pascal
procedure OnStartMapEvent;
var
vFilePath, vFileName: string;
vCopiedOK: boolean;
begin
// split full file name into path and name portions ...
vFilePath := ExtractFilePath(Source.FileCon.CurrentFileName);
vFileName := ExtractFileName(Source.FileCon.CurrentFileName);
// place a copy of the file in a different directory ...
vCopiedOK := Source.FileCon.CopyFile(vFilePath + 'SpareCopy\', vFileName);
if vCopiedOK then
LogInfo('Source file has been copied')
else
LogError('Error creating copy of file');
end;

Description ​

When a File Definition is used with an Action, the CopyFile function can be called to create a copy of a file to a specified location and with a specified name.

CopyFile returns True if the file copying is successful; CopyFile returns False if the copying fails. CopyFile will fail if the specified values are not allowed as a file path or file name .

The CopyFile function does not realign the File Con to the new file. Any further functionality like Transports or Move To Audit will continue to use the original file.

If the target directory path does not exist, Flow will attempt to create it automatically.

File utility functions such as ExtractFileName are described under Scripting Reference, Functions, File.

Also, for file activity not involving Flow Source or Destination files, see Windows File Functions.