M
MYLoveMyFate
Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TForm_SJbf.BitBtn1Click(Sender: TObject);
var
s,d:string;
SrcFile,DestFile:File;
BytesRead,BytesWritten,ToTalRead:Integer;
Buffer:Array[1..500] of byte;
Fsize:integer;
begin
panel7.Visible:=true;
s:=S_URL.Caption;
d:=D_URL.Caption;
if s='' then
begin
showmessage('请选择源文件名!!');
abort;
end;
if D='' then
begin
showmessage('请选择目标文件名!!');
abort;
end;
with gzda_dm.ADODataSet10 do begin
first;
edit;
fieldbyname('S_URL').AsString:=s;
fieldbyname('D_URL').AsString:=d;
post;
UpdateBatch(arALL);
end;
AssignFile(SrcFile,s);
AssignFile(DestFile,d);
ReSet(SrcFile,1); //运行出错后,箭头停在这,报错I/O error 32
try
Rewrite(destFile,1);
try
try
TotalRead:=0;
Fsize:=filesize(SrcFile);
repeat
BlockRead(SrcFile,Buffer,Sizeof(Buffer),BytesRead);
if BytesRead>0 then
begin
BlockWrite(DEStFile,Buffer,BytesRead,BytesWritten);
if BytesRead<>BytesWritten then
Raise Exception.Create('文件拷贝出错!!')
else
begin
ToTalRead:=ToTalRead+BytesRead;
Prbcopy.Position:=Trunc(TotalRead/FSize)*100;
PrbCopy.Update;
end;
end ;
until bytesRead=0;
except
Erase(DestFile);
Raise;
end;
finally
CloseFile(DestFile);
end;
Finally
CloseFile(SrcFile);
end;
showmessage('数据库备份完毕!!');
panel7.Visible:=false;
end;
var
s,d:string;
SrcFile,DestFile:File;
BytesRead,BytesWritten,ToTalRead:Integer;
Buffer:Array[1..500] of byte;
Fsize:integer;
begin
panel7.Visible:=true;
s:=S_URL.Caption;
d:=D_URL.Caption;
if s='' then
begin
showmessage('请选择源文件名!!');
abort;
end;
if D='' then
begin
showmessage('请选择目标文件名!!');
abort;
end;
with gzda_dm.ADODataSet10 do begin
first;
edit;
fieldbyname('S_URL').AsString:=s;
fieldbyname('D_URL').AsString:=d;
post;
UpdateBatch(arALL);
end;
AssignFile(SrcFile,s);
AssignFile(DestFile,d);
ReSet(SrcFile,1); //运行出错后,箭头停在这,报错I/O error 32
try
Rewrite(destFile,1);
try
try
TotalRead:=0;
Fsize:=filesize(SrcFile);
repeat
BlockRead(SrcFile,Buffer,Sizeof(Buffer),BytesRead);
if BytesRead>0 then
begin
BlockWrite(DEStFile,Buffer,BytesRead,BytesWritten);
if BytesRead<>BytesWritten then
Raise Exception.Create('文件拷贝出错!!')
else
begin
ToTalRead:=ToTalRead+BytesRead;
Prbcopy.Position:=Trunc(TotalRead/FSize)*100;
PrbCopy.Update;
end;
end ;
until bytesRead=0;
except
Erase(DestFile);
Raise;
end;
finally
CloseFile(DestFile);
end;
Finally
CloseFile(SrcFile);
end;
showmessage('数据库备份完毕!!');
panel7.Visible:=false;
end;