我有一个zip文件作为嵌入式资源。使用以下代码:
Stream zipStream;
zipStream = thisAssembly.GetManifestResourceStream("Namespace.Resources.zipfile.zip");
byte[] data = Decompress(zipStream);
public static byte[] Decompress(Stream zipStream)
{
ZipInputStream zipInputStream = new ZipInputStream(zipStream);
//zipInputStream.CanDecompressEntry is false
ZipEntry zipEntry;
MemoryStream zipoutStream = new MemoryStream();
while((zipEntry = zipInputStream.GetNextEntry()) != null)
{
byte[] buffer = new byte[zipInputStream.Length];
zipInputStream.Read(buffer, 0, (int)zipInputStream.Length);
zipoutStream.Read(buffer, 0, buffer.Length);
}
return zipoutStream.ToArray();
}
解压缩方法始终返回null。 CanDecompressEntry始终为false。解压缩嵌入资源的其他任何方式?
答案 0 :(得分:1)
问题可能在于“zipoutStream.Read”而不是“zipoutStream.Write”?