这只要使用一个shfileoperation()函数就搞定,下面程序运行通过,给分吧
var
path:string;
opstruc:tshfileopstruct;
frombuf,tobuf:array[0..128] of char;
begin
path:=getexepath;
path:=filepath+'data/*.*';
fillchar(frombuf,sizeof(frombuf),0);
fillchar(tobuf,sizeof(tobuf),0);
strpcopy(frombuf,filepath);
strpcopy(tobuf,pchar(directorylistbox1.Directory));
with opstruc do begin
wnd:=handle;
wfunc:=fo_copy;
pfrom:=@frombuf;
pto:=@tobuf;
fflags:=fof_noconfirmation or fof_renameoncollision;
fanyoperationsaborted:=false;
hnamemappings:=nil;
lpszprogresstitle:=nil;
end;
if shfileoperation(opstruc)=0 then
messagedlg('文件备份成功!',mtinformation,[mbok],0)
else
showmessage('备份失败!请于我联系');
close;
end;