Sharpziplib uncompress embedded resource
I have a zip file as an embedded resource. Using the following code:
Stream zipStream;
zipStream = thisAssembly.GetManifestResourceStream("Namespace.Resources.zipfile.zip");
byte[] data = Decompress(zipStream);
public static byte[] Decompress(Stream zipStream)
{
ZipInputStrea开发者_如何学Cm 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();
}
The decompress method always returns null. CanDecompressEntry is always false. Any other way to unzip embedded resources?
Maybe the problem is in "zipoutStream.Read" instead of "zipoutStream.Write"?
精彩评论