ICSharpCode.SharpZipLib.Zip 解析时报错System.NotSupportedException: No data is available for encoding 936
分析原因
利用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的更多相关文章
- 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 ...
- 使用NPOI读取Excel报错ICSharpCode.SharpZipLib.Zip.ZipException:Wrong Local header signature
写了一个小程序利用NPOI来读取Excel,弹出这样的报错: ICSharpCode.SharpZipLib.Zip.ZipException:Wrong Local header signature ...
- C#调用 ICSharpCode.SharpZipLib.Zip 实现解压缩功能公用类
最近想用个解压缩功能 从网上找了找 加自己修改,个人感觉还是比较好用的,直接上代码如下 using System; using System.Linq; using System.IO; using ...
- 利用ICSharpCode.SharpZipLib.Zip进行文件压缩
官网http://www.icsharpcode.net/ 支持文件和字符压缩. 创建全新的压缩包 第一步,创建压缩包 using ICSharpCode.SharpZipLib.Zip; ZipOu ...
- 使用ICSharpCode.SharpZipLib.Zip实现压缩与解压缩
使用开源类库ICSharpCode.SharpZipLib.Zip可以实现压缩与解压缩功能,源代码和DLL可以从http://www.icsharpcode.net/OpenSource/SharpZ ...
- 基于ICSharpCode.SharpZipLib.Zip的压缩解压缩
原文:基于ICSharpCode.SharpZipLib.Zip的压缩解压缩 今天记压缩解压缩的使用,是基于开源项目ICSharpCode.SharpZipLib.Zip的使用. 一.压缩: /// ...
- c#重命名文件,报错“System.NotSupportedException”类型的未经处理的异常在 mscorlib.dll 中发生”
修改远程服务器的文件名,报错“System.NotSupportedException”类型的未经处理的异常在 mscorlib.dll 中发生”,“System.NotSupportedExcept ...
- ICSharpCode.SharpZipLib.Zip
//压缩整个目录下载 var projectFolder = Request.Params["folder"] != null ? Request.Params["fol ...
- 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 ...
- c# ICSharpCode.SharpZipLib.Zip实现文件的压缩
首先了解ZipOutPutStream和ZipEntry对象 ZipOutPutStream对象 如果要完成一个文件或文件夹的压缩,则要使用ZipOutputStream类.ZipOutputStre ...
随机推荐
- Goland环境中Go module配置
[现象] 从go vendor切换到go module之后,import包解析有问题.如下所示: 对应的go modules也没解析出来 [原因] 有两点原因: goland中go module配置存 ...
- KubeEdge的云边协同设计原理
1.云端组件与K8s Master的关系 cloudCore和K8s master,非侵入的映射 2.EdgeController详解 -边缘节点管理 -应用状态元数据云边协同 3.DeviceCon ...
- 基于python的数学建模---轮廓系数的确定
直接上代码 from sklearn import metrics import matplotlib.pyplot as plt from sklearn.cluster import KMeans ...
- (GCC) C++代码中使用#pragma GCC optimize / #pragma G++ optimize
科学计算用优化 经过实验证明这个命令优化效果最好,把我的 1.2S 的 FFT 优化到了 0.4S使用 pragma 命令优化程序: #pragma GCC optimize("Ofast, ...
- <七>深入理解new和delete的原理
new ,delete 运算符 int *p =new int; delete p; 看一下汇编代码 可以看到new 和delete 运算符其实也是 operator运算符重载函数的调用 malloc ...
- (小白向)2020-12-18 中国大学MOOC第十二讲-动态变量应用
1创建单向链表(10分) 问题描述:根据随机输入的若干非零整数,以数字0结束:建立一个新链表. 输入:随机输入若干个整数,以数字0结束 输出:新建链表中个节点的值,数字间没有间隔字符. 样例:输入 5 ...
- 学习ASP.NET Core Blazor编程系列十六——排序
学习ASP.NET Core Blazor编程系列文章之目录 学习ASP.NET Core Blazor编程系列一--综述 学习ASP.NET Core Blazor编程系列二--第一个Blazor应 ...
- pycharm恢复删除文档与查询修改前数据
1.pycharm恢复删除文档 第一步: 第二步: 2.pycharm查询修改前文档数据 第一步: 第二步:
- input限制只能输入汉字
<el-form class="det_foot" :model="form" :rules="rules" ref="fo ...
- 递归实现指数型枚举 (n个可选可不选)
递归实现指数型枚举 从 1∼n 这 n 个整数中随机选取任意多个,输出所有可能的选择方案. 输入格式 输入一个整数 n. 输出格式 每行输出一种方案. 同一行内的数必须升序排列,相邻两个数用恰好 1 ...