我很抱歉保守的標題和我的問題本身,但我迷路了。如何在流中使用ICSharpCode.ZipLib?
ICsharpCode.ZipLib提供的示例不包括我正在搜索的內容。 我想通過將其放入InflaterInputStream(ICSharpCode.SharpZipLib.Zip.Compression.Streams.InflaterInputStream)來解壓縮一個字節[]
我找到了一個解壓縮函數,但它不起作用。
public static byte[] Decompress(byte[] Bytes)
{
ICSharpCode.SharpZipLib.Zip.Compression.Streams.InflaterInputStream stream =
new ICSharpCode.SharpZipLib.Zip.Compression.Streams.InflaterInputStream(new MemoryStream(Bytes));
MemoryStream memory = new MemoryStream();
byte[] writeData = new byte[4096];
int size;
while (true)
{
size = stream.Read(writeData, 0, writeData.Length);
if (size > 0)
{
memory.Write(writeData, 0, size);
}
else break;
}
stream.Close();
return memory.ToArray();
}
它拋出在線路異常(大小= stream.Read(寫數據,0,writeData.Length);)說它具有無效報頭。
我的問題不是如何修復函數,這個函數沒有提供庫,我只是發現它googling.My的問題是,如何解壓縮與InflaterStream功能相同的方式,但沒有例外。
再次感謝 - 抱歉保守的問題。