c# - How to convert a pdf to a memory stream -
I am writing an application in MVC4.
I have a physical PDF file on the server, I want to convert it to a memory stream and send it back to the user like this:
Return file ( Stream, "app / pdf", "ipdf pdf"); But how do I convert a PDF file to the storage stream?
Thank you!
You do not need memorystream . The easiest way to overload the file name is to: return file (@ "c: \ mimefile pdf", "application / pdf"); Another solution is to use overload which accepts byte [] : returns file (System.IO .File.ReadAllBytes (@ "C: \ MyFile PDF"), "Application / PDF"); or if you want to use FileStream : Return file (new filestream (@ "C: \ MyFile PDF ", FileMode.Open, FileAccess.Read)," Application / PDF ");
Comments
Post a Comment