一个很简单的问题(100分)

  • 主题发起人 主题发起人 yinqiang1983
  • 开始时间 开始时间
Y

yinqiang1983

Unregistered / Unconfirmed
GUEST, unregistred user!
http://delphibbs.com/delphibbs/dispq.asp?lid=2281135
 
移动文件sName到dName:
Function MoveFile(const sName, dName: string): Boolean;
var
sOld, sObj: AnsiString;
lpFileOp: TSHFileOpStruct;
begin
Sold := PChar(sName) + #0#0;
sObj := PChar(dName) + #0#0;
with lpFileOp do
begin
Wnd := Application.Handle;
wFunc := FO_MOVE;
pFrom := PChar(sold);
pTo := PChar(sObj);
fFlags := FOF_ALLOWUNDO;
hNameMappings := nil;
lpszProgressTitle := nil;
fAnyOperationsAborted := True;
end;
Result := SHFileOperation(lpFileOp) = 0;
end;
 
//带进度条的复制文件函数

Procedure CopyFileWithProgressBar(Source, Destination: string; aGauge: TGauge);
var
FromF, ToF : file of byte;
Buffer : array[0..4096] of char;
NumRead : integer;
FileLength : longint;
begin
AssignFile(FromF, Source);
reset(FromF);
AssignFile(ToF, Destination);
rewrite(ToF);
FileLength:=FileSize(FromF);
With aGauge do begin
MinValue := 0; Progress := 0;
MaxValue := FileLength;
while FileLength > 0 do begin
BlockRead(FromF, Buffer[0], SizeOf(Buffer), NumRead);
FileLength := FileLength - NumRead;
BlockWrite(ToF, Buffer[0], NumRead);
Progress := Progress + NumRead;
end;
CloseFile(FromF);
CloseFile(ToF);
end;
end;
 
多人接受答案了。
 
后退
顶部