Difference between revisions of "CopyFile"
From Free Pascal wiki
Jump to navigationJump to search (mention lclbase) |
|||
Line 31: | Line 31: | ||
'''Function result''' | '''Function result''' | ||
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}} | ||
+ | |||
[[category:Lazarus]] | [[category:Lazarus]] | ||
[[category:fileutil]] | [[category:fileutil]] | ||
[[Category:Code]] | [[Category:Code]] |
Revision as of 08:11, 22 July 2014
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
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