分析原因

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

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

错误代码

  1. using (ZipInputStream zip = new ZipInputStream(File.OpenRead(path)))
  2. {
  3. using (var filestream = new FileStream(path, FileMode.Open, FileAccess.Read))
  4. {
  5. // 出现错误部分
  6. ZipFile zipfile = new ZipFile(filestream);
  7. foreach (ZipEntry entry in zipfile)
  8. {
  9. if (entry != null)
  10. {
  11. if (entry.Name.ToLower() == "androidmanifest.xml")
  12. {
  13. manifestData = new byte[50 * 1024];
  14. Stream strm = zipfile.GetInputStream(entry);
  15. strm.Read(manifestData, 0, manifestData.Length);
  16. }
  17. if (entry.Name.ToLower() == "resources.arsc")
  18. {
  19. Stream strm = zipfile.GetInputStream(entry);
  20. using (BinaryReader s = new BinaryReader(strm))
  21. {
  22. resourcesData = s.ReadBytes((int)entry.Size);
  23. }
  24. }
  25. }
  26. }
  27. }
  28. }

解决方法

  1. using (ZipInputStream zip = new ZipInputStream(File.OpenRead(path)))
  2. {
  3. using (var filestream = new FileStream(path, FileMode.Open, FileAccess.Read))
  4. {
  5. // 在.Net Core中默认System.Text中不支持CodePagesEncodingProvider.Instance
  6. // 添加下方这行代码允许访问.Net Framework平台上不支持的编码提供程序
  7. System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
  8. ZipFile zipfile = new ZipFile(filestream);
  9. foreach (ZipEntry entry in zipfile)
  10. {
  11. if (entry != null)
  12. {
  13. if (entry.Name.ToLower() == "androidmanifest.xml")
  14. {
  15. manifestData = new byte[50 * 1024];
  16. Stream strm = zipfile.GetInputStream(entry);
  17. strm.Read(manifestData, 0, manifestData.Length);
  18. }
  19. if (entry.Name.ToLower() == "resources.arsc")
  20. {
  21. Stream strm = zipfile.GetInputStream(entry);
  22. using (BinaryReader s = new BinaryReader(strm))
  23. {
  24. resourcesData = s.ReadBytes((int)entry.Size);
  25. }
  26. }
  27. }
  28. }
  29. }
  30. }

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. Go语言核心36讲38

    到目前为止,我们已经一起陆陆续续地学完了Go语言中那些最重要也最有特色的概念.语法和编程方式.我对于它们非常喜爱,简直可以用如数家珍来形容了. 在开始今天的内容之前,我先来做一个简单的总结. Go语言 ...

  2. Go语言核心36讲36

    在前面,我几乎已经把Go语言自带的同步工具全盘托出了.你是否已经听懂了会用了呢? 无论怎样,我都希望你能够多多练习.多多使用.它们和Go语言独有的并发编程方式并不冲突,相反,配合起来使用,绝对能达到& ...

  3. WSL优化之SSH远程登录篇

    Some of the most devastating things that happen to you will teach you the most. 有些最打击你的事情反而教会你的东西越多. ...

  4. 基于python的数学建模---场线与数值解(微分方程)

    import numpy as np from scipy import integrate import matplotlib.pyplot as plt import sympy def plot ...

  5. C温故补缺(六):C反汇编常用的AT&Tx86语法

    C语言反汇编用到的AT&T x86汇编语法 参考:CSDN1,CSDN2 默认gcc -S汇编出的,以及反汇编出的,都是AT&T x86代码,可以用-masm=intel指定为inte ...

  6. 关于python3调用matplotlib中文乱码问题

    问题描述 我用来绘制柱形图,横坐标上面的数据, 但是网上大部分说的都是更改横纵坐标标签的乱码问题,而不是横坐标数据乱码问题 解决办法 更改横纵坐标上标签的中文不乱码 import matplotlib ...

  7. 疫情可视化part3

    前言 之前在part2中说的添加自定义主题配色已经开发完成了,除此之外我还添加了一些的3d特效. 前期文章 这是part1的文章:https://blog.csdn.net/xi1213/articl ...

  8. if-else 的优美写法

    前言‍♂️ 相信大家或多或少都接触过拥有庞大 if else 的项目代码吧,多重嵌套的 if else 在维护的时候真的让人很恼火,有时候一个 bug 排查下来,严重感觉身体被掏空. 本文并未有消灭或 ...

  9. git相关问题解析,你想要的都有🔥

    官网文档: https://git-scm.com/doc 本地克隆远程代码仓库 git clone 地址 本地同步全量历史数据,克隆所有文件的历史记录 git clone 地址 -depth 1 本 ...

  10. [OpenCV实战]31 使用OpenCV将一个三角形仿射变换到另一个三角形

    目录 1 什么是仿射变换? 2 使用OpenCV进行三角形仿射变换 2.1 定义输入和输出 2.2 计算边界框 2.3 裁剪图像和更改坐标 2.4 计算仿射变换矩形 2.5 应用仿射变换到三角形 2. ...