private void RunBackup(string targetdir) { var failed = new List <string>(); foreach (var junkNode in SelectedJunk) { try { junkNode.Backup(targetdir); } catch (Exception ex) { var displayName = junkNode.GetDisplayName(); failed.Add(ex.Message + " - " + displayName); Console.WriteLine($"Backup failed for item {displayName} with exception: {ex}"); } } if (failed.Any()) { failed.Sort(); // Prevent the dialog from getting too large if (failed.Count > 6) { failed = failed.Take(5).Concat(new[] { "... (check log for the full list)" }).ToList(); } if (MessageBoxes.BackupFailedQuestion(string.Join("\n", failed.ToArray()), this) != MessageBoxes.PressedButton.Yes) { throw new OperationCanceledException(); } } }
private bool RunBackup(string targetdir) { var failed = new List <string>(); foreach (var junkNode in SelectedJunk) { try { junkNode.Backup(targetdir); } catch { failed.Add(junkNode.FullName); } } if (failed.Any()) { failed.Sort(); if (MessageBoxes.BackupFailedQuestion(string.Join("\n", failed.ToArray()), this) != MessageBoxes.PressedButton.Yes) { return(false); } } return(true); }
private void RunBackup(string targetdir) { var failed = new List <string>(); foreach (var junkNode in SelectedJunk) { try { junkNode.Backup(targetdir); } catch { failed.Add(junkNode.GetDisplayName()); } } if (failed.Any()) { failed.Sort(); if (MessageBoxes.BackupFailedQuestion(string.Join("\n", failed.ToArray()), this) != MessageBoxes.PressedButton.Yes) { throw new OperationCanceledException(); } } }
private void saveFileDialogBackupRegistry_FileOk(object sender, CancelEventArgs e) { try { var regPaths = SelectedJunk.OfType <RegistryJunkNode>().Select(x => x.FullName); RegistryTools.ExportRegistry(saveFileDialogBackupRegistry.FileName, regPaths); } catch (Exception ex) { if (MessageBoxes.BackupFailedQuestion(ex.Message) == MessageBoxes.PressedButton.Cancel) { e.Cancel = true; } } }