分析原因

利用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. 【Android逆向】rpc调用某安App的X-App-Token签名函数

    阅读此文档的过程中遇到任何问题,请关注公众号[移动端Android和iOS开发技术分享]或加QQ群[309580013] 1.目标 在学习的过程中,会遇到有些算法比较麻烦,没有办法直接还原.那我们就另 ...

  2. php + layui 文件上传 以及 拖拽上传

    HTML: <div id="box"> <div id="drop_area">将文件拖拽到此区域</div> <d ...

  3. Training: WWW-Robots

    原题链接:http://www.wechall.net/challenge/training/www/robots/index.php 打开网页他给我们说什么 说什么这是一个小挑战,你将会了解到机器人 ...

  4. esp-01和esp-01s烧录固件和程序

    准备工具 USB-TTL 杜邦线若干 esp-01s烧录固件 我烧录的固件是 micropython, 使用的软件是 uPyCraft esp-01s烧录固件接线方法: esp-01s usb-ttl ...

  5. kettle 链接oracle12c

    jdbc连接cdb数据库时,url兼容以下2种模式: "jdbc:oracle:thin:@192.168.75.131:1521:oracle12c" "jdbc:or ...

  6. 【每日一题】2021年12月6日-剑指 Offer 22. 链表中倒数第k个节点

    输入一个链表,输出该链表中倒数第k个节点.为了符合大多数人的习惯,本题从1开始计数,即链表的尾节点是倒数第1个节点. 例如,一个链表有 6 个节点,从头节点开始,它们的值依次是 1.2.3.4.5.6 ...

  7. 配置文件 数据库存储引擎 严格模式 MySQL字段基本数据类型

    目录 字符编码与配置文件 \s查看MySQL相关信息 修改配置文件my-default.ini 解决5.6版本字符编码问题 配置文件什么时候加载? 偷懒操作:输入mysql直接登录root账户 数据库 ...

  8. C#-将进程注册为子进程,父进程崩溃的时候子进程也随之退出的方案和实例

    C#-将进程注册为子进程,父进程崩溃的时候子进程也随之退出的方案和实例 Kill child process when parent process is killed 我正在使用我的应用程序中的Sy ...

  9. 小技巧 EntityFrameworkCore 实现 CodeFirst 通过模型生成数据库表时自动携带模型及字段注释信息

    今天分享自己在项目中用到的一个小技巧,就是使用 EntityFrameworkCore 时我们在通过代码去 Update-Database 生成数据库时如何自动将代码模型上的注释和字段上的注释携带到数 ...

  10. Jenkins&&gitlab

    DevOps 强调整个组织的合作以及交付和基础设施变更的自动化 gitlab下载: 下载地址: https://docs.gitlab.com/ee/install/requirements.html ...