Difference between revisions of "CopyFile"

From Free Pascal wiki
Jump to navigationJump to search
(mention lclbase)
m
Line 32: Line 32:
 
Returns True if successful, False if there was an error
 
Returns True if successful, False if there was an error
  
{{Note|You can also use this function in command line programs by adding a project requirement for LCLBase, 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 LCLBase, which will not pull in the entire LCL}}
  
 
[[category:Lazarus]]
 
[[category:Lazarus]]
 
[[category:fileutil]]
 
[[category:fileutil]]
 
[[Category:Code]]
 
[[Category:Code]]

Revision as of 11:03, 29 September 2014

Template:Translate

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