用 TFDSQLiteBackup 控件, 兩三行代碼即可完成 Sqlite 數據庫的備份.
procedure TForm1.Button1Click(Sender: TObject); begin {先初始化目標} FDConnection1.DriverName := 'SQLite'; FDConnection1.Params.Add('Database=C:\Temp\FDDemo_Back.sdb'); //如果不指定這個路徑, 就是備份到內存 FDConnection1.Open(); {備份 C:\Temp\FDDemo.sdb} FDSQLiteBackup1.DriverLink := FDPhysSQLiteDriverLink1; FDSQLiteBackup1.Database := 'C:\Temp\FDDemo.sdb'; //支持 Url FDSQLiteBackup1.DestDatabaseObj := FDConnection1.CliObj; FDSQLiteBackup1.Backup; end;