【发布时间】:2011-04-12 22:33:07
【问题描述】:
我遇到了这个测试函数的问题,我在内存中获取一个字符串,压缩它,然后解压缩它。压缩效果很好,但我似乎无法让解压工作。
//Compress
System.IO.MemoryStream outStream = new System.IO.MemoryStream();
GZipStream tinyStream = new GZipStream(outStream, CompressionMode.Compress);
mStream.Position = 0;
mStream.CopyTo(tinyStream);
//Decompress
outStream.Position = 0;
GZipStream bigStream = new GZipStream(outStream, CompressionMode.Decompress);
System.IO.MemoryStream bigStreamOut = new System.IO.MemoryStream();
bigStream.CopyTo(bigStreamOut);
//Results:
//bigStreamOut.Length == 0
//outStream.Position == the end of the stream.
我相信 bigStream out 至少应该包含数据,尤其是在读取我的源流 (outStream) 时。这是 MSFT 的错误还是我的?
【问题讨论】: