private void SearchBtn_Click(object sender, RoutedEventArgs e) { try { this.PathToDeleteFrom = DirNameTextBox.Text; this.DefaultPath = this.pathToDeleteFrom; } catch (Exception caught) { DisplayDeletedFolders.Text = caught.Message; DeleteBtn.Visibility = Visibility.Collapsed; return; } RemoveFiles.ClearList(); this.listOfDirsToDelete = RemoveFiles.FindObjBinDirectories(this.PathToDeleteFrom); if (this.listOfDirsToDelete.Count > 0) { DisplayDeletedFolders.Text = string.Join(Environment.NewLine, listOfDirsToDelete); DeleteBtn.Visibility = Visibility.Visible; } else { DeleteBtn.Visibility = Visibility.Collapsed; DisplayDeletedFolders.Text = "No Obj or Bin folders found."; } }
protected override void Load(JObject json) { UpdateMinVersion = new Version(json.ReadRequiredValue <string>("updateMinVersion")); UpdateMaxVersion = new Version(json.ReadRequiredValue <string>("updateMaxVersion")); foreach (var child in json.ReadToken("removeFiles").Values <string>()) { RemoveFiles.Add(child); } }
/// <summary> /// This will remove all directories in the list. /// NO checks are done regarding documents to keep, so make sure they are copied somewhere safe. /// </summary> public static bool Clean() { bool noErrors = true; if (RemoveDirs != null && RemoveDirs.Count > 0) { Queue <string> dirs = new Queue <string>(); RemoveDirs.ForEach((x) => { dirs.Enqueue(x); }); RemoveDirs.Clear(); while (dirs.Count > 0) { try { var qdir = dirs.Dequeue(); if (!Directory.Exists(qdir)) { continue; // as we delete recurseivly, check to avoid not found errors } Directory.Delete(qdir, true); } catch (Exception) { noErrors = false; } } } if (RemoveFiles != null && RemoveFiles.Count > 0) { Queue <string> files = new Queue <string>(); RemoveFiles.ForEach((x) => { files.Enqueue(x); }); RemoveFiles.Clear(); while (files.Count > 0) { try { var qfile = files.Dequeue(); if (!File.Exists(qfile)) { continue; // as we delete recurseivly, check to avoid not found errors } File.Delete(qfile); } catch (Exception) { noErrors = false; } } } return(noErrors); }
private void DataGrid_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Delete) { var selected = WatchList.SelectedItems.Cast <object>().ToArray(); e.Handled = true; var result = MessageBox.Show("削除", "選択された要素をしますか?", MessageBoxButton.YesNo, MessageBoxImage.Warning); if (result != MessageBoxResult.Yes) { return; } RemoveFiles?.Invoke(this, new DataGridEventArgs(selected)); } }
//string SQLZoneList(int _iis, double _gain) //{ // string ret = null; // for (int iz = 0; iz < MZone.Count; iz++) // { // ret += string.Format("{0}Z{1}={2}", // iz == 0 ? "" : ",", // (iz + 1).ToString(), // Math.Round(MZone[iz].MSensor[_iis].Level * _gain, 5).ToString(NFI)); // } // return (ret); //} public void SaveBINDKB2_Msg() { SaveFilePars spars = ParAll.ST.Defect.Some.SaveFile; RemoveFiles.RemoveMsg(spars, "bindkb2"); if (spars.Path == null || spars.Path.Length == 0) { return; } try { SaveBINDKB2(FileName); } catch (Exception e) { System.Windows.Forms.MessageBox.Show("Не могу записать файл: " + FileName + " " + e.Message); } }
private void DeleteBtn_Click(object sender, RoutedEventArgs e) { var userInput = WinForms.MessageBox .Show(string.Format("Are you sure sure you want to delete all /obj and /bin folders in {0}?", this.PathToDeleteFrom), "Confirm", MessageBoxButtons.OKCancel); if (userInput == WinForms.DialogResult.OK) { var result = new List <string>(); try { result = RemoveFiles.RemoveFolder(this.listOfDirsToDelete); } catch (Exception) { DisplayDeletedFolders.Text = "Unable to delete all files/"; } if (result.Count == 0) { DisplayDeletedFolders.Text = "Operation Complete."; } else { result.Insert(0, "Unable to delete: "); DisplayDeletedFolders.Text = string.Join(Environment.NewLine, result); } DeleteBtn.Visibility = Visibility.Collapsed; } else { DirNameTextBox.Text = "Operation canceled."; DeleteBtn.Visibility = Visibility.Hidden; } }
public static bool BuildLists(string baseDir) { if (RemoveDirs == null) { RemoveDirs = new List <string>(); } if (RemoveFiles == null) { RemoveFiles = new List <string>(); } RemoveDirs.Clear(); RemoveFiles.Clear(); DocsToKeep.Clear(); string[] dirs = Directory.EnumerateDirectories(baseDir, "*", SearchOption.AllDirectories).ToArray(); bool hasMultiCsv = dirs.Any(x => x.Contains(_csvDir)); if (!hasMultiCsv) { return(false); } AppConst.SetDataCsvPath(dirs.Where(x => x.TrimEnd(Path.DirectorySeparatorChar).EndsWith(_csvDir)).First()); for (int x = 0; x < dirs.Length; x++) { if (!AppConst.DataCsvPath.Contains(dirs[x]) && !dirs[x].Equals(AppConst.TmpPath)) { RemoveDirs.Add(dirs[x]); } else { if (!dirs[x].Equals(AppConst.DataCsvPath) && !dirs[x].Equals(AppConst.TmpPath)) { RemoveFiles.AddRange(Directory.EnumerateFiles(dirs[x])); } } } string docsDir = dirs.Where(x => x.Contains("Documents")).FirstOrDefault(); if (!string.IsNullOrEmpty(docsDir)) { var docfiles = Directory.EnumerateFiles(docsDir, "*.csv").ToList(); var cRegex = new Regex(_countyRegex, RegexOptions.IgnoreCase); for (int x = 0; x < docfiles.Count; x++) { if (cRegex.IsMatch(docfiles[x])) { DocsToKeep.Add(docfiles[x]); } } } if (DocsToKeep.Count != AppConst.ExpectedDocumentsCount) { if (DocsToKeep.Count == 0) { //scan tmp for csv files if (Directory.Exists(AppConst.TmpPath)) { DocsToKeep = Directory.EnumerateFiles(AppConst.TmpPath, "*.csv").ToList(); } } if (DocsToKeep.Count != AppConst.ExpectedDocumentsCount) { Console.Write("DOCUMENT COUNT INCORRECT - "); } } return(true); }