public void Undelete(DataDrive drive, List<string> fileNames) { List<FileRecord> files = new List<FileRecord>(); foreach (FileRecord r in drive.Deletes) if (fileNames.Contains(r.FullPath)) files.Add(r); if (files.Count == 0) { LogFile.Log("No files to undelete."); return; } LogFile.Log("Beginning undelete for {0} file{1}", files.Count, files.Count == 1 ? "" : "s"); cancel = false; recoverTotalBlocks = 0; errorFiles.Clear(); Progress = 0; try { foreach (FileRecord r in files) recoverTotalBlocks += r.LengthInBlocks; recoverBlocks = 0; int errors = 0; int restored = 0; foreach (FileRecord r in files) { if (RecoverFile(r, drive.Root)) { restored++; drive.Deletes.Remove(r); drive.MaybeRemoveAddByName(r.FullPath); } else if (!cancel) errors++; if (cancel) break; else { string statusMsg = String.Format("{0} file{1} restored.", restored, restored == 1 ? "" : "s"); if (errors > 0) statusMsg += " Errors: " + errors; Status = statusMsg; } } } finally { drive.Progress = 0; drive.Status = ""; } }