Sharpziplib 解压缩嵌入资源
我有一个 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。还有其他方法来解压嵌入资源吗?
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)
{
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();
}
The decompress method always returns null. CanDecompressEntry is always false. Any other way to unzip embedded resources?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许问题出在“zipoutStream.Read”而不是“zipoutStream.Write”?
Maybe the problem is in "zipoutStream.Read" instead of "zipoutStream.Write"?