偶現在用delphi+access開發,想做文件備份功能,請問如何實現對數據庫文件的復制,並粘貼后改名的操作?
高手可否供示例代碼?謝了.

解决方案 »

  1.   

    CopyFile('復制文件名', '新文件名', 是否覆蓋);
      

  2.   

    FileName:=ExtractFilePath(paramstr(0))+'\DataBase\Data.mdb';   //取得源文件路径
    SaveFile:= Rzbuttonedit1.Text +'\'+Rzedit1.Text +'.mdb';    //目标文件路径
    if FileExists(SaveFile) then
    begin
      if Application.MessageBox('是否覆盖原来的文件?', '提示', Mb_YesNo or Mb_Iconquestion) = idyes then
      try
        DeleteFile(SaveFile);
      except
        exit;
      end;
    end;
    try
      copyfile(pchar(filename),pchar(savefile),false);
      Application.MessageBox('备份成功!', '提示', Mb_ok or Mb_Iconinformation);
    except
      Application.MessageBox('备份失败!', '提示', Mb_ok or Mb_Iconerror);
    end;