private void lv_files_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e) { MyFileInfo t = (MyFileInfo)lv_files.SelectedItem; FileInfo file = new FileInfo(t.path); try { Process.Start(file.ToString()); } catch { MessageBox.Show("Не удалось открыть выбранный файл!", "ERROR"); return; } }
private void Mn_delete_Click(object sender, RoutedEventArgs e) { MyFileInfo t = (MyFileInfo)lv_files.SelectedItem; // если элемент не был выделен, selectedItem = null if (t == null) { MessageBox.Show("Файл не выбран", "ERROR"); return; } FileInfo file = new FileInfo(t.path); // полный путь к файлу хранится в его свойстве path try { file.Delete(); // пытаемся удалить файл } catch { MessageBox.Show("Выбранный файл невозможно удалить", "ERROR"); return; } MessageBox.Show("Файл \"" + file.Name + "\" успешно удалён", "SUCCESS"); updateInfos(); }