[Overview][Constants][Types][Classes][Procedures and functions][Index] Reference for unit 'FileUtil' (#lazutils)

CopyFile

Copies the source file to the destination file using the specified options.

Declaration

Source position: fileutil.pas line 201

function CopyFile(

  const SrcFilename: string;

  const DestFilename: string;

  Flags: TCopyFileFlags = [cffOverwriteFile];

  ExceptionOnError: Boolean = False

):Boolean;

function CopyFile(

  const SrcFilename: string;

  const DestFilename: string;

  PreserveTime: Boolean;

  ExceptionOnError: Boolean = False

):Boolean;

Arguments

SrcFilename

  

The source file name for the copy operation.

DestFilename

  

The destination file name for the copy operation.

Flags

  

Set with flags enabled for the copy operation.

ExceptionOnError

  

If True, and exception is raised if the copy operation cannot be performed.

Function result

Returns True if successful, False if there was an error.

Arguments

SrcFilename

  

The source file name for the copy operation.

DestFilename

  

The destination file name for the copy operation.

PreserveTime

  

If True, the timestamp of the original file is preserved in the copied file.

ExceptionOnError

  

If True, and exception is raised if the copy operation cannot be performed.

Description

CopyFile is an overloaded Boolean function used to copy the file in SrcFilename to the destination in DestFilename. Both parameters contain a fully-qualified path with file name and extension (if needed) for the respective files.

Flags contains TCopyFileFlag value(s) that are enforced in the copy operation. The default value for the parameter is [cffOverwriteFile] and indicates that the destination file is overwritten if it already exists on the local file system.

PreserveTime indicates if the timestamp for the source file is preserved in the destination file when the copy operation has been completed. It is an alternative to using the Flags arguments in the overloaded variant.

The return value is set to True when the copy operation has been completed successfully. Otherwise, the return value is False.

Errors

An Exception is raised if the copy process does not complete successfully or correctly.


Version 3.2 Generated 2024-02-25 Home