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;   

相关阅读 >>

Delphi 存储文件到数据库

Delphi tdragimage v0.1 Delphi 图片拖拽组件 带有加速度 碰撞效果

Delphi窗口显示于parent控件上

Delphi xe 如何使用自带皮肤

Delphi 的tstringbuilder防止服务器内存碎片化

Delphi 压缩图片(bmp、jpg、png)

使用indy解决base64回车换行问题

Delphi 在win32程序中显示dos调试窗口

Delphi与进程、窗口句柄、文件属性、程序运行状态

tsqlconnection连接mysql(utf8)的问题

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



打赏

取消

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

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

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

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

评论

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