File functions

Top  Previous  Next

 

function CopyFile(Source: string; Target: string; Overwrite: Boolean = False): Boolean;

Copies the Source file to Target.  If Target is a directory, the file is copied to the Target directory using the original file name.  If Target is a file name, Source is copied to the Target directory using the new file name.  Returns True if the Source was successfully copied.

 

procedure CopyFiles(Source: string; TargetFolder: string);

Copies all files matching the Source pattern to the TargetFolder directory.  Source can use wildcards e.g. g:\images\*.png.

 

function CreateDirectory(FolderName: string): Boolean;

Creates the FolderName directory and returns True if successful.

 

procedure DeleteFile(FileName: string; Recursive: Boolean = False);

Delete the FileName file.  If Recursive is True, deletes all files of the same name in the subdirectories too.

 

function DeleteDirectory(FolderName: string): Boolean;

Deletes the FolderName directory and returns True if successful.

 

function DirectoryIsEmpty(FolderName: string): Boolean;

Returns True if the FolderName directory is empty.

 

function EmptyDirectory(FolderName: string): Boolean;

Deletes all files and folders in the FolderName directory, and returns True if successful.

 

procedure ReplaceTagWithFileContents(FileName: string; Tag: string; ContentsFileName: string);

Replaces all occurences of Tag in the FileName file, with the contents of the ContentsFileName file.