Quantcast
Channel: SharpDevelop Community
Viewing all articles
Browse latest Browse all 1764

Looking for a way to use a compressed memory stream for writing and reading

$
0
0

Good time of the day everyone!

I just came across a CodeProject page that pointed me at this community. It talked about using SharpZipLib used with Memory Stream. This is an interesting concept, but I have not been successful using the same approach :( He used this code:

                m_msBZip2 = new MemoryStream();
                m_osBZip2 = new BZip2OutputStream(m_msBZip2);
                m_osBZip2.Write(Encoding.ASCII.GetBytes(txtRawData.Text), 0, txtRawData.Text.Length);
                m_osBZip2.Finalize(); // this apparently writes out all data and makes it available in the memory stream

Then it is possible to get the memory stream contents using ToArray(), but the stream is closed! How can I read from the underlying memory stream without having to create another copy of the compressed data in memory?

Thank you!


Viewing all articles
Browse latest Browse all 1764

Trending Articles