我正在使用 ICSharpCode.SharpZipLib 尝试从网络上解压缩文件,我需要做的就是获取未压缩的字节数组。但是我收到错误“InvalidOperationException:无法从此流中读取”。我在 Unity3D 中使用 c# 工作,目标是 webplayer。它显然是可读的,所以我不确定这个问题。这是我的代码,非常感谢任何帮助。
using (MemoryStream s = new MemoryStream(bytes))
{
using (BinaryReader br = new BinaryReader(s))
{
using (ICSharpCode.SharpZipLib.Zip.ZipInputStream zip = new ICSharpCode.SharpZipLib.Zip.ZipInputStream(s))
{
byte[] bytesUncompressed = new byte[32768];
while (true)
{
Debug.Log("can read: " + zip.CanRead);
int read = zip.Read(bytesUncompressed, 0, bytesUncompressed.Length);
if (read <= 0)
break;
zip.Write(bytesUncompressed, 0, read);
}
}
}
}