分析原因

利用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. Linux Framebuffer 实验

    一.准备 linux虚拟机或ARM开发板 Ubuntu18.04 二.Framebuffer介绍 次笔记主要的目的是实验,所以我不介绍了,有需要的小伙伴可以去看下面博客 Linux LCD Framb ...

  2. UWSGI 安装出现 ModuleNotFoundError: No module named '_ctypes'

    原因:Python3中有个内置模块叫ctypes,它是Python3的外部函数库模块,它提供兼容C语言的数据类型,并通过它调用Linux系统下的共享库(Shared library),此模块需要使用C ...

  3. 【云原生 · Kubernetes】Kubernetes简介及基本组件

    1.Kubernetes简介 Kubernetes是Google开源的容器集群管理系统,其提供应用部署.维护. 扩展机制等功能,如图1.3所示.利用Kubernetes能方便地管理跨机器运行容器化的应 ...

  4. Kafka Connect学习

    一.基础介绍 1.概念 2.Debezium 为捕获数据更改(change data capture,CDC)提供了一个低延迟的流式处理平台.可以消费数据库每一个行级别(row-level)的更改. ...

  5. java抽象类的定义和使用

    1. 抽象类的规则 ● 抽象类不可以被实例化,也就是不能被new,会出现编译错误.抽象类如果想实例化可以通过非抽象子类的方式去实现. ● 抽象类中不一定有抽象方法,但有抽象方法的类一定是抽象类.而且抽 ...

  6. this关键字在JAVA和JS中的异同

    this在JS中的用法 由于js中this 是在运行期进行绑定的,所以js中的 this 可以是全局对象.当前对象或者任意对象,这完全取决于函数的调用方式.JavaScript 中函数的调用有以下几种 ...

  7. PHP-表单传值

    一.传值引入 了解传值必须要先知道为什么需要传值? 传值的主要作用是为了实现用户数据的定制化,用户与服务端的互交 二.传值的方式 虽然 http协议中有很多数据传输的方式,但在PHP中只有 POST ...

  8. 快速学会慢查询SQL排查

    转载请注明出处️ 作者:测试蔡坨坨 原文链接:caituotuo.top/c56bd0c5.html 你好,我是测试蔡坨坨. 在往期文章中,我们聊过数据库基础知识,可参考「数据库基础,看完这篇就够了! ...

  9. 【基于OpenAI的ChatGPT】搭建属于自己的微信聊天机器人(附带注册英国手机号码方式)

    前言:这几天 OpenAI的聊天机器人很火,前两天也爆发了很多关于ChatGPT接入微信的文章.我就顺便[借用别人已有的项目],来部署一个属于自己的微信聊天机器人.项目地址见下文. 1.首先需要有一个 ...

  10. hashlib模块、subprocess模块、loggin日志模块及实战

    hashlib加密模块 目录 hashlib加密模块 加密补充说明 subprocess模块 logging日志模块 日志的组成 日志配置字典 配置参数 1.何为加密 将明文数据处理成密文数据 让人无 ...