public void DeleteFile(ClassFsItem itemToDelete, MainWindow owindow) { itemToDelete.DeleteFile(); owindow.ListFile.Items.Remove(itemToDelete); owindow.ListFile.Items.Refresh(); }
private void BtnDelete_click(object sender, RoutedEventArgs e) { if (ListFile.SelectedItem != null) { if (ListFile.SelectedItems.Count == 1) { if (MessageBox.Show(((ClassFsItem)ListFile.SelectedItem).DeleteText, "Delete", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes) { _oScan.DeleteFile((ClassFsItem)ListFile.SelectedItem, this); } } else { ClassFsItem[] selected = new ClassFsItem[ListFile.SelectedItems.Count]; ListFile.SelectedItems.CopyTo(selected, 0); if (MessageBox.Show("Do you want to delete all the selected file.", "Delete", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes) { foreach (ClassFsItem itm in selected) { _oScan.DeleteFile(itm, this); } } } } }
public void DeleteFile(ClassFsItem itemToDelete) { if (itemToDelete.Type == "File") { _duplicateFile[((ClassFile)itemToDelete).Md5()].Remove((ClassFile)itemToDelete); File.Delete(itemToDelete.Name); } else { DeleteRepDuplicate((ClassDirectory)itemToDelete); Directory.Delete(itemToDelete.Name, false); } }
public void AddLine(ClassFsItem itm) { ListFile.Items.Add(itm); }