我正在使用 smo 使用这种编码,但什么也没发生。
Restore res = new Restore();
res.Devices.AddDevice(@"D:\Shivam.bak", DeviceType.File);
BackupDeviceItem bkpDevice = new BackupDeviceItem(@"\\hqsqlbkup1\VN\Shivam.bak", DeviceType.File);
res.Database = "ShivamDb";
res.Action = RestoreActionType.Database;
res.RelocateFiles.Add(new RelocateFile("Shivam", @"+ System.Windows.Forms.Application.StartupPath +\\Shivam.mdf"));
res.RelocateFiles.Add(new RelocateFile("Shivam_log", @"System.Windows.Forms.Application.StartupPath + \\Shivam_log.ldf"));
res.ReplaceDatabase = true;
MessageBox.Show("Restore complited");