私は ICSharpCode.SharpZipLib を使用して、Web からファイルを解凍しようとしています。必要なのは、圧縮されていないバイト配列を取得することだけです。ただし、「InvalidOperationException: Unable to read from this stream」というエラーが表示されます。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);
}
}
}
}