【发布时间】:2017-04-15 22:32:43
【问题描述】:
我有一个完全有效的 zip 文件,它只包含一个打包文件,可以通过外部实用程序解压缩,它不会让 DeflateStream 有任何有用的东西。我已经删除了前两个字节前缀(“50h 4Bh”,这些前缀总是产生“块长度与其补码不匹配”异常),但是没有任何进展 - unzipped[] 总是包含零并且 Read 也返回 0。
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);
}
}
}
【问题讨论】:
标签: .net compression deflate