示例#1
0
        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);
        }
示例#2
0
 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);
         }
     }
 }