public bool Delete() { List <IFileData> selectedFiles = GetSelectedFiles(); if (selectedFiles.Count > 0 && MessageBox.Show(this, "Delete selected file(s)?", "Confirm", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.OK) { foreach (IFileData file in selectedFiles) { if (file.IsUrl) { //can't delete a remote file... } else { FileInfo fi = new FileInfo(Path.Combine(DataDirectory.GetFullPath(), file.FileName)); DataSourceAdapter.DeleteFile(file); try { fi.Delete(); } catch { } } } return(true); } return(false); }
public void HandleDeleteSaveGames(string[] deletedFiles, IFileData[] previousFiles) { foreach (var file in deletedFiles) { FileInfo fi = new FileInfo(file); IFileData saveFile = previousFiles.FirstOrDefault(x => x.OriginalFileName == fi.Name); if (saveFile != null) { DataSourceAdapter.DeleteFile(saveFile); } } }