Difference between revisions of "CopyFile"

From Lazarus wiki
Jump to navigationJump to search
Line 1: Line 1:
 +
{{CopyFile}}
  
 
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)
Line 32: Line 33:
  
 
{{Note|If you want to use this function in command line programs, add a project requirement for LazUtils, which will not pull in the entire LCL}}
 
{{Note|If you want to use this function in command line programs, add a project requirement for LazUtils, which will not pull in the entire LCL}}
 
[[category:Lazarus]]
 
[[category:fileutil]]
 
[[Category:Code]]
 

Revision as of 21:09, 22 November 2016

English (en) suomi (fi) français (fr) русский (ru)

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 LazUtils, which will not pull in the entire LCL