登录 用户中心() [退出] 后台管理 注册
   
您的位置: 首页 >> SoftHub关联区 >> 主题: lazarus 的 copyfile 函数所在单元及库     [回主站]     [分站链接]
lazarus 的 copyfile 函数所在单元及库
clq
浏览(359) - 2020-11-03 18:03:58 发表 编辑

关键字:

lazarus 的 copyfile 函数所在单元及库

和 delphi7 还是很不同。在单元 fileutil 中,并且要包含库 LazUtils 。

----------------------------------------------------------------
参考 https://wiki.freepascal.org/CopyFile

CopyFile

│ 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;

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

Function result Returns boolean value True if successful, False if there was an error.
Note-icon.png

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
Windows example

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


Lazarus example

The following components or functions are used in this example::

TOpenDialog topendialog.png
TSaveDialog tsavedialog.png
MessageDlg


procedure TForm1.Button1Click(Sender: TObject);
var
ok:boolean;
begin
ok := false;
if OpenDialog1.Execute then
if SaveDialog1.Execute then
ok := CopyFile(OpenDialog1.FileName, SaveDialog1.FileName);
if ok then MessageDlg('File '+OpenDialog1.FileName+' successfully copied to '+
SaveDialog1.FileName,mtInformation,[mbOk],0)
else MessageDlg('Copying failed',mtWarning,[mbOk],0);
end;




总数:0 页次:1/0 首页 尾页  
总数:0 页次:1/0 首页 尾页  


所在合集/目录
lazarus不同于delphi的地方 更多



发表评论:
文本/html模式切换 插入图片 文本/html模式切换


附件:



NEWBT官方QQ群1: 276678893
可求档连环画,漫画;询问文本处理大师等软件使用技巧;求档softhub软件下载及使用技巧.
但不可"开车",严禁国家敏感话题,不可求档涉及版权的文档软件.
验证问题说明申请入群原因即可.

Copyright © 2005-2020 clq, All Rights Reserved
版权所有
桂ICP备15002303号-1