In my class, I receive a WordprocessingDocument object as a return from another method. I know the document was created in-memory (MemoryStream).
Now, I need to either get the underlying MemoryStream of this WordprocessingDocument object, or resave it to a new MemoryStream.
I need it as MemoryStream so I can transfer it to our repository.
How can I either access the underlying MemoryStream, or resave the object to a new MemoryStream?
You can clone the
WordprocessingDocumentinto a newMemoryStreamlike this:I tested it with a console project below: