I am unable to stream a word document that I create on the fly down to the browser. I am constantly getting a message from Microsoft Word that the document is corrupt.
As variant for .NET Framework 3.5 and lower. This version of framework haven't method CopyTo
in class Stream
. Therefore, method WriteTo
is replaced by next code:
byte[] arr = documentStream.ToArray();
fileStream.Write(arr, 0, arr.Length);
Example was found by http://blogs.msdn.com/b/mcsuksoldev/archive/2010/04/09/creating-a-new-microsoft-word-document-from-a-template-using-openxml.aspx