コード例 #1
0
        public ActionResult Delete(int id)
        {
            Platformus.FileManager.Data.Entities.File file = this.Storage.GetRepository <IFileRepository>().WithKey(id);

            try
            {
                System.IO.File.Delete(this.GetPathAndFilename(file.Name));
            }

            catch { }

            this.Storage.GetRepository <IFileRepository>().Delete(file);
            this.Storage.Save();
            return(this.RedirectToAction("Index"));
        }
コード例 #2
0
        public ActionResult Delete(int id)
        {
            Platformus.FileManager.Data.Entities.File file = this.Storage.GetRepository <IFileRepository>().WithKey(id);

            try
            {
                System.IO.File.Delete(this.GetFilepath(file.Name));
            }

            catch { }

            this.Storage.GetRepository <IFileRepository>().Delete(file);
            this.Storage.Save();
            Event <IFileDeletedEventHandler, IRequestHandler, Platformus.FileManager.Data.Entities.File> .Broadcast(this, file);

            return(this.RedirectToAction("Index"));
        }
コード例 #3
0
        public async Task <IActionResult> Create(IList <IFormFile> files)
        {
            foreach (IFormFile source in files)
            {
                string filename = ContentDispositionHeaderValue.Parse(source.ContentDisposition).FileName.Trim('"');

                filename = this.EnsureCorrectFilename(filename);

                using (FileStream output = System.IO.File.Create(this.GetPathAndFilename(filename)))
                    await source.CopyToAsync(output);

                Platformus.FileManager.Data.Entities.File file = new Platformus.FileManager.Data.Entities.File();

                file.Name = filename;
                file.Size = source.Length;
                this.Storage.GetRepository <IFileRepository>().Create(file);
                this.Storage.Save();
            }

            return(this.RedirectToAction("Index"));
        }