分析原因

利用ICSharpCode.SharpZipLib.Zip进行APK解析时,因为APK内编译的名称为中文,查询微软开发文档936为gb2312中文编码

微软开发文档地址https://docs.microsoft.com/zh-cn/windows/win32/intl/code-page-identifiers

错误代码

using (ZipInputStream zip = new ZipInputStream(File.OpenRead(path)))
{
using (var filestream = new FileStream(path, FileMode.Open, FileAccess.Read))
{ // 出现错误部分
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);
}
}
}
}
}
}

解决方法

using (ZipInputStream zip = new ZipInputStream(File.OpenRead(path)))
{
using (var filestream = new FileStream(path, FileMode.Open, FileAccess.Read))
{
// 在.Net Core中默认System.Text中不支持CodePagesEncodingProvider.Instance
// 添加下方这行代码允许访问.Net Framework平台上不支持的编码提供程序
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);
}
}
}
}
}
}

ICSharpCode.SharpZipLib.Zip 解析时报错System.NotSupportedException: No data is available for encoding 936的更多相关文章

  1. System.NotSupportedException:“No data is available for encoding 1252. For information on defining a custom encoding

    最近搞 .net项目,Dapper连接Mysql时,运行报错: System.NotSupportedException:“No data is available for encoding 1252 ...

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

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

  3. C#调用 ICSharpCode.SharpZipLib.Zip 实现解压缩功能公用类

    最近想用个解压缩功能 从网上找了找 加自己修改,个人感觉还是比较好用的,直接上代码如下 using System; using System.Linq; using System.IO; using ...

  4. 利用ICSharpCode.SharpZipLib.Zip进行文件压缩

    官网http://www.icsharpcode.net/ 支持文件和字符压缩. 创建全新的压缩包 第一步,创建压缩包 using ICSharpCode.SharpZipLib.Zip; ZipOu ...

  5. 使用ICSharpCode.SharpZipLib.Zip实现压缩与解压缩

    使用开源类库ICSharpCode.SharpZipLib.Zip可以实现压缩与解压缩功能,源代码和DLL可以从http://www.icsharpcode.net/OpenSource/SharpZ ...

  6. 基于ICSharpCode.SharpZipLib.Zip的压缩解压缩

    原文:基于ICSharpCode.SharpZipLib.Zip的压缩解压缩 今天记压缩解压缩的使用,是基于开源项目ICSharpCode.SharpZipLib.Zip的使用. 一.压缩: /// ...

  7. c#重命名文件,报错“System.NotSupportedException”类型的未经处理的异常在 mscorlib.dll 中发生”

    修改远程服务器的文件名,报错“System.NotSupportedException”类型的未经处理的异常在 mscorlib.dll 中发生”,“System.NotSupportedExcept ...

  8. ICSharpCode.SharpZipLib.Zip

    //压缩整个目录下载 var projectFolder = Request.Params["folder"] != null ? Request.Params["fol ...

  9. mysql5.7.12/13在安装新实例时报错:InnoDB: auto-extending data file ./ibdata1 is of a different size 640 pages (rounded down to MB) than specified in the .cnf file: initial 768 pages, max 0 (relevant if non-zero

    .bin/mysqld --initialize-insecure --basedir=xxx --datadir=xxx 然后 .bin/mysqld_safe --defaults-file=xx ...

  10. c# ICSharpCode.SharpZipLib.Zip实现文件的压缩

    首先了解ZipOutPutStream和ZipEntry对象 ZipOutPutStream对象 如果要完成一个文件或文件夹的压缩,则要使用ZipOutputStream类.ZipOutputStre ...

随机推荐

  1. 安装kali linux(干货)

    安装kali 一. 准备工具 1. VMware Workstation Pro https://www.vmware.com/cn/products/workstation-pro/workstat ...

  2. 核磁共振成像学习笔记——从FID信号到K空间

    在理想磁场环境下(没有不存在场不均匀性),对于一个没有梯度场的方块. 此时,RF pulse的两路正交信号(相位差为90°)对此方块进行激发,然后收取信号,我们可以得到由此方块产生的FID信号. 设此 ...

  3. PHY驱动调试之 --- PHY控制器驱动(二)

    1. 前言 内核版本:linux 4.9.225,以freescale为例. 2. 概述 PHY芯片为OSI的最底层-物理层(Physical Layer),通过MII/GMII/RMII/SGMII ...

  4. i春秋Test

    点开是个莫名其妙的网站...看看源码, 第一排好像有点东西 最后也有点东西,所以我们直接百度海洋CMS漏洞(https://www.freebuf.com/vuls/150042.html) 所以这里 ...

  5. Blazor组件自做十二 : Blazor Pdf Reader PDF阅读器 组件 (草稿)

    原文链接 [https://www.cnblogs.com/densen2014/p/16954812.html] Blazor Pdf Reader PDF阅读器 组件 应小伙伴要求撸了一个简单的P ...

  6. L1-064 估值一亿的AI核心代码 (20分)

    L1-064 估值一亿的AI核心代码 (20分) 以上图片来自新浪微博. 本题要求你实现一个稍微更值钱一点的 AI 英文问答程序,规则是: 无论用户说什么,首先把对方说的话在一行中原样打印出来: 消除 ...

  7. Kafka技术专题之「性能调优篇」消息队列服务端出现内存溢出OOM以及相关性能调优实战分析

    内存问题 本篇文章介绍Kafka处理大文件出现内存溢出 java.lang.OutOfMemoryError: Direct buffer memory,主要内容包括基础应用.实用技巧.原理机制等方面 ...

  8. 记一次InputStream流读取不完整留下的惨痛教训

    前言 首先,问问大家下面这段流读取的代码是否存在问题呢? inputStream = .... try { // 根据inputStream的长度创建字节数组 byte[] arrayOfByte = ...

  9. jQuery事件与动态效果

    目录 一:阻止后续事件执行 1.推荐使用阻止事件 2.未使用 阻止后续事件执行 3.使用阻止后续事件执行 二:阻止事件冒泡 1.什么是事件冒泡? 2.未阻止事件冒泡 3.阻止事件冒泡 4.2.阻止冒泡 ...

  10. C#从实习到搬砖

    日常唠唠 没事就聊聊我在c#上踩过的那些坑,和一些笔记 少点比较,多些谦虚 会者不难 原博:轩先生大冒险 2022.4.19 datagridview 修改表头 dataGridView1.Colum ...