Procedure TFm_DBBackUp.CopyFileWithProgressBar(Source,Destination : string);<br>var<br> FromF,ToF : file of byte;<br> Buffer : array[0..4096] of char;<br> NumRead : integer;<br> FileLength : longint;<br>begin<br> AssignFile(FromF,Source);<br> reset(FromF);<br> AssignFile(ToF,Destination);<br> rewrite(ToF);<br> FileLength:=FileSize(FromF);<br> With Progressbar1 do<br> begin<br> Min := 0;<br> Max := FileLength;<br> while FileLength > 0 do<br> begin<br> BlockRead(FromF,Buffer[0],SizeOf(Buffer),NumRead);<br> FileLength := FileLength - NumRead;<br> BlockWrite(ToF,Buffer[0],NumRead);<br> Position := Position + NumRead;<br> end;<br> end;<br> CloseFile(FromF);<br> CloseFile(ToF);<br>end;<br><br><br>procedure TFm_DBBackUp.BtnBackUpClick(Sender: TObject);<br>var<br> databasepath,newpath,filename:string;<br>begin<br> if (Trim(edit1.Text)='')then<br> begin<br> application.MessageBox('请选择路径','提示',mb_oK+MB_ICONINFORMATION);<br> Exit;<br> end;<br> //if application.MessageBox('确定','提示',mb_okcancel)=ID_OK then<br> btnclose.Enabled:=False;<br> DataBasepath:=ExtractFileDir(paramstr(0));<br> DataBasepath:=DataBasepath+'/gdzc.mdb';<br> filename:=datetimetostr(date())+'.bak';<br> newpath:=edit1.Text+'/'+filename;<br> if dm.ADOConnection1.Connected then<br> dm.ADOConnection1.Close;<br> if fileExists(newpath) then<br> begin<br> if application.MessageBox('当天的数据备份已存在,是否覆盖?','提示',mb_okcancel)=ID_OK then<br> //copyfile(pchar(DataBasePath),pchar(newpath),False)<br> CopyFileWithProgressBar(DataBasePath,newpath)<br> else<br> exit;<br> end<br> else<br> begin<br> //copyfile(pchar(DataBasePath),pchar(newpath),True);<br> CopyFileWithProgressBar(DataBasePath,newpath);<br> end;<br> btnclose.Enabled:=true;<br> application.MessageBox('数据备份成功!','提示',mb_ok);<br> dm.ADOConnection1.Open();<br> Self.Close;<br><br>end;<br><br><br>自己整理一下,肯定OK了,很简单的,到网上搜索一下