Short and simple answer to the question with "Memory stream is not expanding": Do not open the document from MemoryStream. Therefore, in this regard, the earlier answer is correct, just open the file.
Opening a document from MemoryStream to edit a document (in my experience) will easily result in a "memory stream not expanding." I believe that the message appears when edited, which requires an expansion of the memory stream. I found that I can make some changes, but not everything that adds size. Thus, f.ex deletes the user part of xml in order, but adding one and some data is not.
So, if you really need to open a memory stream, you have to figure out how to open an expandable MemoryStream if you want to add to it. I need this and hope to find a solution.
Stein-Tore Erdal
PS: just noticed the answer from "January 26, 2011 at 15:18". Do not think that this is the answer in all situations. I get an error when trying:
var ms = new MemoryStream(bytes); using (WordprocessingDocument wd = WordprocessingDocument.Open(ms, true)) { ... using (MemoryStream msData = new MemoryStream()) { xdoc.Save(msData); msData.Position = 0; ourCxp.FeedData(msData);
source share