更新文件还原

来源:互联网 发布:淘宝商家客服 编辑:程序博客网 时间:2024/05/16 04:42

procedure TForm1.Button3Click(Sender: TObject);
var
sFilename:string;
sIn:string;
begin
sIn:=extractfilepath(application.ExeName)+'update.ini';
try
 if fileexists(sIn) then
      begin
      //文件进行备份
        sFilename:= extractfilepath(application.ExeName)+'update~1.ini' ;
        if FileExists(sFileName) then
           DeleteFile( sFilename);
        Copyfile(pChar(sIn),pChar(sFilename),false); //文件复制
      end;
      raise Exception.Create('dddd');
 except
    if FileExists(sIn) then  //删除当前文件
           DeleteFile(sin);
     Copyfile(pChar(sFilename),pChar(sIn),false);//还原
    if FileExists(sFilename) then  //删除文件
    DeleteFile(sFilename);
 end;

end;

原创粉丝点击