public IActionResult NewsFile() { var path = $"{_ev.WebRootPath}/File/COVID-19 Education.pdf"; var Memory = new MemoryStream(); using (var Stream = new FileStream(path, FileMode.Open)) { Stream.CopyTo(Memory); } Memory.Position = 0; return(File(Memory, FileExtention.GetContentType(path))); }
public IActionResult Download(int id) { var Lesson = _context.Lessons.Find(id); var path = $"{_ev.WebRootPath}/File/{Lesson.Suammary}"; if (Lesson.Suammary == null) { return(Redirect("/Home/NotFoundFile")); } var Memory = new MemoryStream(); using (var Stream = new FileStream(path, FileMode.Open)) { Stream.CopyTo(Memory); } Memory.Position = 0; return(File(Memory, FileExtention.GetContentType(path), Lesson.Suammary)); }