private void Sort_Button_Click(object sender, RoutedEventArgs e) { if (path != null) { DirectoryInfo files = new DirectoryInfo(path); foreach (FileInfo file in files.GetFiles()) { try { foreach (CategoryClass Category in CategoryList) { if (Category.Formats.Contains(file.Extension) && FileException.Contains(file.Name) == false) { Directory.CreateDirectory($@"{path}\{Category.Name}\"); fullDirectoryFile = $@"{file.DirectoryName}\{file.Name}"; File.Move(fullDirectoryFile, $@"{path}\{Category.Name}\{file.Name}"); } } } catch { //Это нужно чтобы обходить файлы, которые заняты другим процессом } } GreetingLab.SetResourceReference(TextBlock.TextProperty, "l_Succ"); } else { GreetingLab.SetResourceReference(TextBlock.TextProperty, "l_PathError"); } }
private void Select_Button_Click(object sender, RoutedEventArgs e) { using (OpenFileDialog selectFile = new OpenFileDialog()) { selectFile.Multiselect = true; if (selectFile.ShowDialog() == DialogResult.OK) { foreach (string file in selectFile.SafeFileNames) { if (FileException.Contains(file) == false) { FileException.Add(file); } } FileExcep_ListView.ItemsSource = null; FileExcep_ListView.ItemsSource = FileException; } } }