使用 C# 和 SMO,当我创建备份时,它们被复制到 SQL Server 使用的默认备份位置 (C:\Program Files\Microsoft SQL Server\MSSQL11.SQLEXPRESS\MSSQL\Backup),而不是我指定的物理位置在代码中:
Database database = Server.Databases[dbName]);
Backup backup = new Backup();
device = new BackupDevice();
device.Parent = Server;
device.Name = dbName + ".bak";
device.BackupDeviceType = BackupDeviceType.Disk;
device.PhysicalLocation = Path.Combine(filePath + device.Name); // doesn't appear to do anything
device.Create();
backup.Action = BackupActionType.Database;
backup.Database = database.Name;
backup.Devices.AddDevice(filePath, DeviceType.File);
backup.SqlBackup(server);
当我运行我的代码时,我发现我指定的路径(“C:\backupTest”)是空的,并且备份已添加到默认备份位置。
有谁知道这是为什么?