我也需要这方面的代码,有哪位大虾知道,请指导,谢谢!!!!!!!!!!111111
[email protected]

解决方案 »

  1.   

    就是将数据库文件复制。
    复制可有Api函数FileCopy,它只能复制指定的文件,所以你要有一个Drivelistbox,directotryListbox,FileListBox(在win31页)将他们连接,FileListBox就会显示你指定的路径的所有文件。
    然后对FileListBox.Item从头至尾循环一边,就把所有的文件拷过去了。
    下面的例子还带了一个进度条显示。panel控件你可以不要
    procedure TEdBackUpForm.BitBtn1Click(Sender: TObject);
    var
     i: Integer;
     FromF,ToF,Path: String;
    begin
      if not DirectoryExists(Edit1.Text) then
        if MessageDlg('该目录不存在,你要创建吗?',mtConfirmation, [mbYes,mbNo], 0) = mrNo then exit
          else if not ForceDirectories(Edit1.Text) then begin  raise Exception.Create('不能创建'+Edit1.Text); exit; end;  Panel1.Visible:= False;
      Panel2.Visible:= True;
      Height:= 163;
      Path:=Edit1.Text;
      DirectoryListBox2.Directory:= 'E:\database\JXC1';  with ProgressBar1 do
      begin
        Min:=0;
        Max:=FileListBox2.Items.Count-1;
        for i:=Min to Max  do
        begin
          FileListBox2.ItemIndex:=i;
          FromF:= FileListBox2.FileName;
          ToF:= Path+'\'+ExtractFileName(FileListBox2.FileName);
          copyfile(PChar(FromF),PChar(ToF),False);
          Position:= i;
          Label5.Refresh;
        end;
        MessageDLG('备份成功!',mtInformation,[mbOk],0);
        Close;
      end;
    end;
    恢复是同样的道理。
    记得给分