delphi 拷贝文件时有进度显示


本文整理自网络,侵删。

 procedure TForm1.mycopyfile(sourcef,targetf:string);
var
FromF, ToF: file;
NumRead, NumWritten: Integer;
Buf: array[1..2048] of Char;
n:integer;
begin
AssignFile(FromF, sourcef);
Reset(FromF, 1); { Record size = 1 }
AssignFile(ToF,targetf); { Open output file }
Rewrite(ToF, 1); { Record size = 1 }
n:=0;
repeat
BlockRead(FromF, Buf, SizeOf(Buf), NumRead);
form1.label1.caption:=IntToStr(sizeof(buf)*n*100 div FileSize(FromF))+'100%';
application.ProcessMessages;
//显示进度
BlockWrite(ToF, Buf, NumRead, NumWritten);
inc(n);
until (NumRead = 0) or (NumWritten <> NumRead);
form1.Label1.Caption:='100%';
CloseFile(FromF);
CloseFile(ToF);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
mycopyfile('e:\123.zip','c:\123.zip');
end;   

相关阅读 >>

firemonkey listbox 的几个事件:拖动,点击,长按

Delphi xe 制作的萤光时钟,可改作屏保

Delphi controls 属性与继承 tshape 类的小练习

cnvcl 组件包

Delphi fmx 把内容复制到粘贴板上支持跨平台

Delphi xe5记录android应用程序(日志输出)

Delphi getprocessmemoryinfo获取进程占用内存大小

Delphi 遍例一个外部程序中所有的类名

Delphi lockbox 做加密解密

Delphi xe5实现datetimetounix/unixtodatetime的一点小改进

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...