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?
MemoryStream encapsulates data stored as an unsigned byte array. The encapsulated data is directly accessible in memory. Memory streams can reduce the need for temporary buffers and files in an application. The current position of a stream is the position at which the next read or write operation takes place.
Save MemoryStream to a String StreamWriter sw = new StreamWriter(memoryStream); sw. WriteLine("Your string to Memoery"); This string is currently saved in the StreamWriters buffer. Flushing the stream will force the string whose backing store is memory (MemoryStream).
As the name suggests, a FileStream reads and writes to a file whereas a MemoryStream reads and writes to the memory. So it relates to where the stream is stored.
This works:
Stream memStream = new MemoryStream();
Package pack = Package.Open(memStream, FileMode.Create);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With