Search code examples
.net-3.5openxmlpackaging

How can I create a Package on a memory stream


Is it possible to create a System.IO.Packaging.Package on a memory stream. I'd like to avoid the file system and do everything in memory if possible.

However, the only way to create a Package is to call Package.Open which accepts a stream. However, if the stream is empty, this fails.

Any clue?


Solution

  • This works:

    Stream memStream = new MemoryStream();
    Package pack = Package.Open(memStream, FileMode.Create);