分析原因

利用ICSharpCode.SharpZipLib.dll解析APK时,进入APK的AndroidXml获取时出现报错

出错代码

using (ICSharpCode.SharpZipLib.Zip.ZipInputStream zip = new ICSharpCode.SharpZipLib.Zip.ZipInputStream(File.OpenRead(path)))
{
using (var filestream = new FileStream(path, FileMode.Open, FileAccess.Read))
{
ICSharpCode.SharpZipLib.Zip.ZipFile zipfile = new ICSharpCode.SharpZipLib.Zip.ZipFile(filestream);
ICSharpCode.SharpZipLib.Zip.ZipEntry item;
// 出错部分
while ((item = zip.GetNextEntry()) != null)
{
if (item.Name.ToLower() == "androidmanifest.xml")
{
manifestData = new byte[50 * 1024];
using (Stream strm = zipfile.GetInputStream(item))
{
strm.Read(manifestData, 0, manifestData.Length);
}
}
if (item.Name.ToLower() == "resources.arsc")
{
using (Stream strm = zipfile.GetInputStream(item))
{
using (BinaryReader s = new BinaryReader(strm))
{
resourcesData = s.ReadBytes((int)s.BaseStream.Length);
}
}
}
}
}

解决方法

经过查阅资料,解决方法如下

using (ZipInputStream zip = new ZipInputStream(File.OpenRead(path)))
{
using (var filestream = new FileStream(path, FileMode.Open, FileAccess.Read))
{
System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
ZipFile zipfile = new ZipFile(filestream);
// 代码更换部分
foreach (ZipEntry entry in zipfile)
{
if (entry != null)
{
if (entry.Name.ToLower() == "androidmanifest.xml")
{
manifestData = new byte[50 * 1024];
Stream strm = zipfile.GetInputStream(entry);
strm.Read(manifestData, 0, manifestData.Length);
}
if (entry.Name.ToLower() == "resources.arsc")
{
Stream strm = zipfile.GetInputStream(entry);
using (BinaryReader s = new BinaryReader(strm))
{
resourcesData = s.ReadBytes((int)entry.Size);
}
}
}
}
}
}

参考链接

Wrong Local header signature: 0xFF8https://github.com/hylander0/Iteedee.ApkReader/issues/20

利用ICSharpCode.SharpZipLib.dll解析 出错:“Wrong Local header signature: 0xFF8”的更多相关文章

  1. C# 下利用ICSharpCode.SharpZipLib.dll实现文件/目录压缩、解压缩

    ICSharpCode.SharpZipLib.dll下载地址 1.压缩某个指定文件夹下日志,将日志压缩到CompressionDirectory文件夹中,并清除原来未压缩日志. #region 压缩 ...

  2. C# 利用ICSharpCode.SharpZipLib.dll 实现压缩和解压缩文件

    我们 开发时经常会遇到需要压缩文件的需求,利用C#的开源组件ICSharpCode.SharpZipLib, 就可以很容易的实现压缩和解压缩功能. 压缩文件: /// <summary> ...

  3. 使用NPOI读取Excel报错ICSharpCode.SharpZipLib.Zip.ZipException:Wrong Local header signature

    写了一个小程序利用NPOI来读取Excel,弹出这样的报错: ICSharpCode.SharpZipLib.Zip.ZipException:Wrong Local header signature ...

  4. ICSharpCode.SharpZipLib.dll 移植WP

    由于众所周知的原因. ICSharpCode.SharpZipLib.dll在Unity移植WP的时候出现诸多API不兼容,解决方案是在在Github上面找ICSharpCode.SharpZipLi ...

  5. C#文件或文件夹压缩和解压方法(通过ICSharpCode.SharpZipLib.dll)

    我在网上收集一下文件的压缩和解压的方法,是通过ICSharpCode.SharpZipLib.dll 来实现的 一.介绍的目录 第一步:下载压缩和解压的 ICSharpCode.SharpZipLib ...

  6. C# ICSharpCode.SharpZipLib.dll文件压缩和解压功能类整理,上传文件或下载文件很常用

    工作中我们很多时候需要进行对文件进行压缩,比较通用的压缩的dll就是ICSharpCode.SharpZipLib.dll,废话不多了,网上也有很多的资料,我将其最常用的两个函数整理了一下,提供了一个 ...

  7. ICSharpCode.SharpZipLib.dll,MyZip.dll,Ionic.Zip.dll 使用

    MyZip.dll : 有BUG,会把子目录的文件解压到根目录.. ICSharpCode.SharpZipLib.dll: 把ICSharpCode.SharpZipLib.dll复制一份,重命名为 ...

  8. C#使用ICSharpCode.SharpZipLib.dll压缩多个文件

    首先通过NuGet管理安装ICSharpCode.SharpZipLib.dll 以下是压缩的通用方法: using System; using System.IO; using System.Web ...

  9. C# ZipHelper C#公共类 -- ICSharpCode.SharpZipLib.dll实现压缩和解压

    关于本文档的说明 本文档基于ICSharpCode.SharpZipLib.dll的封装,常用的解压和压缩方法都已经涵盖在内,都是经过项目实战积累下来的 1.基本介绍 由于项目中需要用到各种压缩将文件 ...

  10. C# 压缩文件 ICSharpCode.SharpZipLib.dll

    效果: 代码只能压缩文件夹里面的文件,不能压缩文件夹. 压缩前: 压缩后: 代码: 需要引用ICSharpCode.SharpZipLib.dll public ActionResult Index( ...

随机推荐

  1. SSH(一)架包的引入

    一年多未使用了,有些东西真的会忘. 一.ssh的图形化记忆运作流程 二.Struts2.hibernate.spring需要引用的jar包 Struts2: 基本开发:struts-2.3.32\ap ...

  2. Dev-Cpp下载与安装

    目录 一.介绍 Dev-Cpp 二.下载 Dev-Cpp 1.通过百度网盘下载 2.通过 SourceForge 官网下载 三.安装 Dev-Cpp 写在结尾的话 免责声明 大家好,这里是 main工 ...

  3. Linux相关命令及软件安装教程

    @font-face { font-family: "Times New Roman" } @font-face { font-family: "宋体" } @ ...

  4. SpringMVC01:入门、请求参数绑定、自定义类型转换器、常见注解

    一.介绍--三层架构和MVC 1.三层架构介绍和MVC设计模型介绍 开发架构一般都是基于两种形式,一种是 C/S 架构,也就是客户端/服务器,另一种是 B/S 架构,也就是浏览器/服务器.在 Java ...

  5. 【每日一题】【与运算判断奇偶】【list的重载前后插入】2021年11月25日-103. 二叉树的锯齿形层序遍历

    给定一个二叉树,返回其节点值的锯齿形层序遍历.(即先从左往右,再从右往左进行下一层遍历,以此类推,层与层之间交替进行). 例如:给定二叉树 [3,9,20,null,null,15,7], 来源:力扣 ...

  6. (四) 一文搞懂 JMM - 内存模型

    4.JMM - 内存模型 1.JMM内存模型 JMM与happen-before 1.可见性问题产生原因 下图为x86架构下CPU缓存的布局,即在一个CPU 4核下,L1.L2.L3三级缓存与主内存的 ...

  7. 从一个 issue 出发,带你玩图数据库 NebulaGraph 内核开发

    如何 build NebulaGraph?如何为 NebulaGraph 内核做贡献?即便是新手也能快速上手,从本文作为切入点就够了. NebulaGraph 的架构简介 为了方便对 NebulaGr ...

  8. 前缀树(Tire)—Python

    核心思想 空间换时间,是一种用于快速减速的多叉树结构,利用字符串的公共前缀来降低时间 优缺点: 优点:查询效率高,减少字符比较 缺点:内存消耗较大 每次都会从头向下一直到字符串结尾 前缀树 1 单个字 ...

  9. vue 引入vant 上传图片oss处理

    <van-uploader :before-read="beforeRead" v-model="product.images" max-size=&qu ...

  10. 万万没想到,go的数据库操作,也能像php一样溜了

    Hi,各位go的小伙伴. 很多人都是从php转过来的吧,不知道你们有没有发现,go界的orm并没有像php的orm一样好用.这篇文章里,我们认真的讨论下这个问题,并且会在后面提出解决方案. php的方 ...