H
hcnet
Unregistered / Unconfirmed
GUEST, unregistred user!
Procedure TForm1.CopyFileWithProgressBar(Source,Destination:string);
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 ProgressBar1 do
begin
Min := 0;
Max := FileLength;
while FileLength > 0 do
begin
BlockRead(FromF,Buffer[0],SizeOf(Buffer),NumRead);
FileLength := FileLength - NumRead;
BlockWrite(ToF,Buffer[0],NumRead);
Position := Position + NumRead;
Application.ProcessMessages;
end;
CloseFile(FromF);
CloseFile(ToF);
end;
end;
请问各位兄弟上面的代码为何这个复制文件的时候只能本地磁盘对磁盘复制
CopyFileWithProgressBar('c:/sys.gho','d:/sys.gho');
用网络路径复制 reset(FromF);会报错。。。。。。
请问该如何修改可以做到支持网络路径复制文件呢?
CopyFileWithProgressBar('//192.168.0.251/sys/sys.gho','d:/sys.gho');
源路径://192.168.0.251/sys/sys.gho'
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 ProgressBar1 do
begin
Min := 0;
Max := FileLength;
while FileLength > 0 do
begin
BlockRead(FromF,Buffer[0],SizeOf(Buffer),NumRead);
FileLength := FileLength - NumRead;
BlockWrite(ToF,Buffer[0],NumRead);
Position := Position + NumRead;
Application.ProcessMessages;
end;
CloseFile(FromF);
CloseFile(ToF);
end;
end;
请问各位兄弟上面的代码为何这个复制文件的时候只能本地磁盘对磁盘复制
CopyFileWithProgressBar('c:/sys.gho','d:/sys.gho');
用网络路径复制 reset(FromF);会报错。。。。。。
请问该如何修改可以做到支持网络路径复制文件呢?
CopyFileWithProgressBar('//192.168.0.251/sys/sys.gho','d:/sys.gho');
源路径://192.168.0.251/sys/sys.gho'