private void Backup() { SaveFileDialog dialog = new SaveFileDialog(); dialog.Filter = Files.BackupFileFilter; dialog.CheckPathExists = true; dialog.Title = Resources.SaveBackupDialogTitle; if (dialog.ShowDialog() == DialogResult.OK) { try { BackupFile backup = new BackupFile(this.controller.Status.DataPath, dialog.FileName); backup.BeginCreate(); BackupProgressDialog backupDialog = new BackupProgressDialog(); backupDialog.SetProgress(backup.FileName, backup.Progress); backupDialog.Show(); while (!backup.Complete) { backupDialog.SetProgress(backup.FileName, backup.Progress); Application.DoEvents(); Thread.Sleep(1); } backupDialog.Close(); MessageForm.Show(Resources.SaveBackupDone, Resources.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception exception) { Error.ErrorDialog.ShowError(exception); } } }
private void Backup() { SaveFileDialog dialog = new SaveFileDialog(); dialog.Title = Resources.ChooseCertificateBackupDialog; dialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); dialog.CheckPathExists = true; dialog.OverwritePrompt = true; dialog.Filter = Files.BackupFileFilter; if (dialog.ShowDialog() == DialogResult.OK) { BackupFile backup = new BackupFile(Status.DataPath, dialog.FileName); backup.BeginCreate(); while (!backup.Complete) { Status.SetProgress(Resources.ChooseCertificateBackupRunning, backup.Progress); Thread.Sleep(10); } if (backup.Exception == null) { Status.SetMessage(Resources.ChooseCertificateBackupSuccess, MessageType.Success); } else { Status.SetMessage(Resources.ChooseCertificateBackupFailed + backup.Exception.Message, MessageType.Error); } } }