2017-04-15 8 views
0

私は完全に有効なzipファイルを持っています。これには、正確に1つのパックファイルが含まれています。これは外部ユーティリティを使用して解凍することができ、DeflateStreamから役立たないものはありません。私は最初の2バイトの接頭辞( "50h 4Bh"、常に "ブロック長はその補数と一致しません"という例外があります)を削除しましたが、進捗状況 - 解凍されていない[]は常に0を含み、Readも0を返します。DeflateStream.Readは常にゼロを返します

byte[] zipped = new byte[] { 0x03, 0x04, 0x14, 0x00, 0x00, 0x00, 0x08, 0x00, 0xe4, 0x6e, 0x89, 0x4a, 0x1d, 0x42, 0x8f, 0xb7, 0x1d, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x30, 0x63, 0x64, 0x60, 0x60, 0xa8, 0xd7, 0x0b, 0x62, 0x60, 0xa8, 0x65, 0xc4, 0x8e, 0x41, 0x0a, 0x18, 0x18, 0xeb, 0x41, 0x14, 0xa3, 0x08, 0x03, 0x8c, 0x0f, 0x27, 0x40, 0x00, 0x00, 0x50, 0x4b, 0x01, 0x02, 0x14, 0x00, 0x14, 0x00, 0x00, 0x00, 0x08, 0x00, 0xe4, 0x6e, 0x89, 0x4a, 0x1d, 0x42, 0x8f, 0xb7, 0x1d, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x50, 0x4b, 0x05, 0x06, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x2f, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00 }; 
MemoryStream zipstream = new MemoryStream(zipped); 
byte[] unzipped = new byte[1024]; 
using (MemoryStream unzipstream = new MemoryStream(unzipped)) 
{ 
    using (DeflateStream worker = new DeflateStream(zipstream, CompressionMode.Decompress)) 
    { 
     try 
     { 
      int length = worker.Read(unzipped, 0, 1024); 

      //worker.CopyTo(unzipstream); 
      //Console.Write(unzipstream.Length); 
      //int length = unzipstream.Read(unzipped,0,1024); 
     } 
     catch (Exception ex) 
     { 
      Console.Write(ex.Message); 
     } 
    } 
} 

答えて

1

これはzipファイルであり、zlibストリームではありません。 ZipFileクラスを使用します。

+0

ありがとうございました。 (ZipArchive) DeflateStream defstream0 =(DeflateStream)ziparc.Entries [0] .Open(); バイト[]バッファ=新しいバイト[1024]。 defstream0.Read(buffer、0、1024); ' 私は自分の状況をよりよく説明していたはずです。私はこのアーカイブをバイト[]として受け取っているので、ディスク操作を避けようとしています。 – ZuOverture

+1

この場合、 'ByteArrayInputStream'でラップしたメモリ内配列で動作する' ZipInputStream'を使うことができます。 @ ZuOverture – BeeOnRope

関連する問題