Difference between revisions of "CopyFile"

From Lazarus wiki
Jump to navigationJump to search
m
Line 1: Line 1:
{{Translate}}
 
  
 
Unit: Lazarus [[fileutil]] (UTF-8 replacements for FPC RTL code and additional file/directory handling)
 
Unit: Lazarus [[fileutil]] (UTF-8 replacements for FPC RTL code and additional file/directory handling)

Revision as of 09:38, 11 July 2015

Unit: Lazarus fileutil (UTF-8 replacements for FPC RTL code and additional file/directory handling)

// flags for copy
type
 TCopyFileFlag = (
   cffOverwriteFile,
   cffCreateDestDirectory,
   cffPreserveTime
   );
 TCopyFileFlags = set of TCopyFileFlag;

function CopyFile(const SrcFilename, DestFilename: string): boolean;
function CopyFile(const SrcFilename, DestFilename: string; PreserveTime: boolean): boolean;
function CopyFile(const SrcFilename, DestFilename: string; Flags: TCopyFileFlags=[cffOverwriteFile]): boolean;

copyfile copies a source file to a destination file location. Optionally it preserves the file's timestamp.

Example:

uses 
...
fileutil
...
CopyFile('c:\autoexec.bat','c:\windows\temp\autoexec.bat.backup');

Function result Returns True if successful, False if there was an error

Light bulb  Note: If you want to use this function in command line programs, add a project requirement for LCLBase, which will not pull in the entire LCL