I am trying to create a Win Form that can create a DB backup with the click of a button. I am trying to allow the user to set the directory to where the ".bak" will go.
Here is what I have:
If you look at the BackupDeviceItem, the commented outline is what I want to do. I want to store the backup to that location. But if I only use a filename it works (the uncommented line) and puts the file in "C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup" .HTML Code:if (saveBackupDialog.ShowDialog() == DialogResult.OK) { Backup bu = new Backup(); bu.Action = BackupActionType.Database; bu.Database = "Test"; //database name //BackupDeviceItem bdi = new BackupDeviceItem(saveBackupDialog.FileName, DeviceType.File); BackupDeviceItem bdi = new BackupDeviceItem("Test.bak", DeviceType.File); bu.Devices.Add(bdi); try { Server server = new Server(); //server bu.SqlBackup(server); } catch (Exception x) { MessageBox.Show(x.ToString()); Close(); } }
Basically instead of putting the file in C:\\Program Files... I want it to go where teh user selects from the savedialog. Any help is appreciated.
Thanks




Reply With Quote