Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Last active March 16, 2016 10:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bjoerntx/eaca4743c7fa74873b63 to your computer and use it in GitHub Desktop.
Save bjoerntx/eaca4743c7fa74873b63 to your computer and use it in GitHub Desktop.
public ActionResult Index()
{
Document document = new Models.Document();
MemoryStream ms = new MemoryStream();
FileStream fs;
// load the document into a stream
using (fs = System.IO.File.OpenRead(
Server.MapPath("/App_Data/documents/document.docx")))
{
fs.CopyTo(ms);
document.BinaryDocument = Convert.ToBase64String(ms.ToArray());
}
// forward the document to the view
return View(document);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment