示例#1
0
        public IActionResult DeleteFile(string id, int presentationId, int courseId, int fileId)
        {
            PresentationFiles file     = repository.PresentationFiles.FirstOrDefault(f => f.FileId == fileId);
            string            dirPath  = Path.Combine(hostingEnvironment.WebRootPath, $@"UsersData\{id}\Presentations\");
            string            filePath = Path.Combine(dirPath, file.FileId.ToString() + ".pdf");

            //delete file if exists
            System.IO.File.Delete(filePath);

            repository.DeleteFile(file.FileId);

            return(RedirectToAction("EditPresentation", new { id, presentationId, courseId }));
        }