private void clearSSFN(string steamDIR) { DirectoryInfo d = new DirectoryInfo(steamDIR); int count = 0; foreach (var file in d.GetFiles("ssfn*")) { count++; logPrint($"Deleting: {file.Name}"); try { File.Delete(file.FullName); } catch (Exception ex) { logPrint($"ERROR: {ex.ToString()}"); } } if (count > 0) { logPrint("Done."); CleaningOutput.AppendText(Environment.NewLine); } else { logPrint("No SSFN files found."); } }
private void btnClearBackups_Click(object sender, RoutedEventArgs e) { logPrint("Clearing forgotten account backups:"); mw.ClearForgottenBackups(); logPrint("Done."); CleaningOutput.AppendText(Environment.NewLine); }
private void clearFile(string fl) { FileInfo f = new FileInfo(fl); if (File.Exists(f.FullName)) { logPrint($"Deleting: {f.Name}"); try { File.Delete(f.FullName); } catch (Exception ex) { logPrint($"ERROR: {ex.ToString()}"); } logPrint("Done."); if (fl == "config\\loginusers.vdf") { logPrint("[ Don't forget to clear forgotten account backups as well ]"); CleaningOutput.AppendText(Environment.NewLine); } CleaningOutput.AppendText(Environment.NewLine); } else { logPrint($"{f.Name} was not found."); } }
// SSFN very small, so multi-threading isn't needed. Super tiny freeze of UI is OK. private void ClearSsfn(string steamDir) { var d = new DirectoryInfo(steamDir); var count = 0; foreach (var file in d.GetFiles("ssfn*")) { count++; LogPrint($"Deleting: {file.Name}"); try { File.Delete(file.FullName); } catch (Exception ex) { LogPrint($"ERROR: {ex}"); } } if (count > 0) { LogPrint("Done."); CleaningOutput.AppendText(Environment.NewLine); } else { LogPrint("No SSFN files found."); } }
private void LogPrint(string text) { this.Dispatcher.Invoke(() => { CleaningOutput.AppendText(text + Environment.NewLine); CleaningOutput.ScrollToEnd(); }); }
private void Task_clearFolder(object oin) { // Only allow one to be run at a time if (!Monitor.TryEnter(_lockClearFolder)) { return; } try { var options = (PossibleClearArgs)oin; LogPrint(options.FldName); var count = 0; if (Directory.Exists(options.FolderName)) { var d = new DirectoryInfo(options.FolderName); foreach (var file in d.GetFiles("*.*")) { count++; LogPrint($"Deleting: {file.Name}"); try { File.Delete(file.FullName); } catch (Exception ex) { LogPrint($"ERROR: {ex}"); } } foreach (var subDir in d.GetDirectories()) { count++; LogPrint($"Deleting: {subDir.Name} subfolder and contents"); try { Directory.Delete(subDir.FullName, true); } catch (Exception ex) { LogPrint($"ERROR: {ex}"); } } LogPrint(count == 0 ? $"{options.FolderName} is empty." : "Done."); CleaningOutput.AppendText(Environment.NewLine); } else { LogPrint($"Directory not found: {options.FolderName}"); } } finally { Monitor.Exit(_lockClearFolder); } }
private void clearFolder(string fldName, string fld) { logPrint(fldName); int count = 0; if (Directory.Exists(fld)) { DirectoryInfo d = new DirectoryInfo(fld); foreach (var file in d.GetFiles("*.*")) { count++; logPrint($"Deleting: {file.Name}"); try { File.Delete(file.FullName); } catch (Exception ex) { logPrint($"ERROR: {ex.ToString()}"); } } foreach (var subd in d.GetDirectories()) { count++; logPrint($"Deleting: {subd.Name} subfolder and contents"); try { Directory.Delete(subd.FullName, true); } catch (Exception ex) { logPrint($"ERROR: {ex.ToString()}"); } } if (count == 0) { logPrint($"{fld} is empty."); } else { logPrint("Done."); } CleaningOutput.AppendText(Environment.NewLine); } else { logPrint($"Directory not found: {fld}"); } }
private void Task_clearFilesOfType(object oin) { // Only allow one to be run at a time if (!Monitor.TryEnter(_lockClearFilesOfType)) { return; } try { var options = (PossibleClearArgs)oin; LogPrint(options.FldName); if (Directory.Exists(options.FolderName)) { foreach (var file in GetFiles(options.FolderName, options.FileExtensions, options.SearchOption)) { LogPrint($"Deleting: {file}"); try { File.Delete(file); } catch (Exception ex) { LogPrint($"ERROR: {ex}"); } } this.Dispatcher.Invoke(() => { CleaningOutput.AppendText(Environment.NewLine); }); } else { LogPrint($"Directory not found: {options.FolderName}"); } } finally { Monitor.Exit(_lockClearFilesOfType); } }
private void logPrint(string text) { CleaningOutput.AppendText(text + Environment.NewLine); CleaningOutput.ScrollToEnd(); }