I m与C#合作,视觉演播室,2005年,温树。
I m writing an application that will backup all the DBs in all of our SQL Server instances I m refering
using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlServer.Management.Common;
行动:
- Backup every db on every SQL Server instance.
- copy the backup to a local machine(where the application is running)
- deleting the backup file from the remote server - this actions fails regarding to permission issues
该守则是:
Backup bkpDatabase = new Backup();
// Set the backup type to a database backup
bkpDatabase.Action = BackupActionType.Database;
// Set the database that we want to perform a backup on
bkpDatabase.Database = DbName;// cmbDatabase.SelectedItem.ToString();
// Set the backup device to a file
//new BackupDeviceItem(saveBackupDialog.FileName, DeviceType.File);
BackupDeviceItem bkpDevice = new BackupDeviceItem(NewName, DeviceType.File);
// Add the backup device to the backup
bkpDatabase.Devices.Add(bkpDevice);
// Perform the backup
bkpDatabase.SqlBackup(SD.SrvSql);
File.Copy(Source, PathDestination + "\" + fileName);
File.Delete(Source);
我试图与以下方面合作:
File.Move
File.Delete
他们不工作
提前感谢。