e){entryTotal=e.Item.Size;info_builde1="提取文件:"e.Item.Key";";}privatevoidarchive_FilePartExtractionBegin(objectsender,FilePartExtractionBeginEventArgse){partTotal=e.Size;info_builde2="分卷:"e.Name";";}privatevoidarchive_CompressedBytesRead(objectsender,CompressedBytesReadEventArgse){stringpercentage=entryTotal.HasValue?CreatePercentage(e.CompressedBytesRead,entryTotal.Value).ToString():"Unknown";info_builde=info_builde1info_builde2"字节:"e.CompressedBytesRead";百分比:"percentage"%";this.CrossThreadCalls(()=>{compress_Info.Text=info_builde;progress[1].Value=int.Parse(percentage)>100||int.Parse(percentage)<0?100:int.Parse(percentage);if(volumes<2)progress[0].Value=progress[1].Value;Application.DoEvents();});}privateintCreatePercentage(longn,longd){return(int)(((double)n/(double)d)*100);}-IMDN开发者社群-imdn.cn"> e){entryTotal=e.Item.Size;info_builde1="提取文件:"e.Item.Key";";}privatevoidarchive_FilePartExtractionBegin(objectsender,FilePartExtractionBeginEventArgse){partTotal=e.Size;info_builde2="分卷:"e.Name";";}privatevoidarchive_CompressedBytesRead(objectsender,CompressedBytesReadEventArgse){stringpercentage=entryTotal.HasValue?CreatePercentage(e.CompressedBytesRead,entryTotal.Value).ToString():"Unknown";info_builde=info_builde1info_builde2"字节:"e.CompressedBytesRead";百分比:"percentage"%";this.CrossThreadCalls(()=>{compress_Info.Text=info_builde;progress[1].Value=int.Parse(percentage)>100||int.Parse(percentage)<0?100:int.Parse(percentage);if(volumes<2)progress[0].Value=progress[1].Value;Application.DoEvents();});}privateintCreatePercentage(longn,longd){return(int)(((double)n/(double)d)*100);} - IMDN开发者社群-imdn.cn">
登录
首页 » C# » 解压缩文件示例(rar、zip、7zip、Gzip、tar...等)

解压缩文件示例(rar、zip、7zip、Gzip、tar...等)

于 2019-07-21 发布
0 291
下载积分: 1 下载次数: 1

代码说明:

本程序是基于 sharpcompress-master 设计的演示程序。开原地址:https://github.com/adamhathcock/sharpcompress。1. 程序主要展示了压缩文件的解压缩,支持的文件类型有:rar、zip、7zip、Gzip、tar......等压缩格式,展示了密码解压、分卷解压、解压进度等功能。2. 不支持“带密码的分卷压缩文件”的解压;无密码分卷压缩、单个带密码文件正常解压。3. 此程序在设计中,对组件源代码进行了修改,与原组件代码对照查看。4、sharpcompress-master组件功能繁多,比如,文件压缩为图片、压缩文件内文件添加删除、更名等等,对照现有的压缩软件,功能均具备,可在代码中查看使用。本示例只是展示了解压缩功能。此程序为识别全部压缩格式,未引用DLL,全部为cs文件,如有错误,自行对照修正。private void Uncompress(string archiveFile, string destinationPath, string password = null) { var archive = ArchiveFactory.Open(archiveFile, new ReaderOptions() { Password = password, LeaveStreamOpen = true }); volumes = archive.Entries.Count(); archive.EntryExtractionBegin = archive_EntryExtractionBegin; archive.FilePartExtractionBegin = archive_FilePartExtractionBegin; archive.CompressedBytesRead = archive_CompressedBytesRead; Task.Run(() => { long order = 0; foreach (var entry in archive.Entries) { if (!entry.IsDirectory) { entry.WriteToDirectory(destinationPath, new ExtractionOptions() { ExtractFullPath = true, Overwrite = true, }); } order ; this.CrossThreadCalls(() => { if (volumes > 1) { progress[0].Value = CreatePercentage(order, volumes); } }); } MessageBox.Show("解压缩任务完成 !"); }); } private void archive_EntryExtractionBegin(object sender, ArchiveExtractionEventArgs e) { entryTotal = e.Item.Size; info_builde1 = "提取文件: " e.Item.Key ";"; } private void archive_FilePartExtractionBegin(object sender, FilePartExtractionBeginEventArgs e) { partTotal = e.Size; info_builde2 = "分卷:" e.Name ";"; } private void archive_CompressedBytesRead(object sender, CompressedBytesReadEventArgs e) { string percentage = entryTotal.HasValue ? CreatePercentage(e.CompressedBytesRead, entryTotal.Value).ToString() : "Unknown"; info_builde = info_builde1 info_builde2 "字节:" e.CompressedBytesRead ";百分比:" percentage "%"; this.CrossThreadCalls(() => { compress_Info.Text = info_builde; progress[1].Value = int.Parse(percentage) > 100 || int.Parse(percentage) < 0 ? 100 : int.Parse(percentage); if (volumes < 2) progress[0].Value = progress[1].Value; Application.DoEvents(); }); } private int CreatePercentage(long n, long d) { return (int)(((double)n / (double)d) * 100); }

下载说明:请别用迅雷下载,失败请重下,重下不扣分!

发表评论

0 个回复

  • C# Addin Vsto Excel小插 实例源码下载
    可以根据表头筛选excel数据,并且把筛选好的数据保存到时另一个表中
    2017-06-22下载
    积分:1
  • 压缩示例(rar、zip、7zip、Gzip、tar...等)
    本程序是基于 sharpcompress-master 设计的演示程序。开原地址:https://github.com/adamhathcock/sharpcompress。1. 程序主要展示了压缩文件的解压缩,支持的文件类型有:rar、zip、7zip、Gzip、tar......等压缩格式,展示了密码解压、分卷解压、解压进度等功能。2. 不支持“带密码的分卷压缩文件”的解压;无密码分卷压缩、单个带密码文件正常解压。3. 此程序在设计中,对组件源代码进行了修改,与原组件代码对照查看。4、sharpcompress-master组件功能繁多,比如,文件压缩为图片、压缩文件内文件添加删除、更名等等,对照现有的压缩软件,功能均具备,可在代码中查看使用。本示例只是展示了解压缩功能。此程序为识别全部压缩格式,未引用DLL,全部为cs文件,如有错误,自行对照修正。private void Uncompress(string archiveFile, string destinationPath, string password = null) { var archive = ArchiveFactory.Open(archiveFile, new ReaderOptions() { Password = password, LeaveStreamOpen = true }); volumes = archive.Entries.Count(); archive.EntryExtractionBegin = archive_EntryExtractionBegin; archive.FilePartExtractionBegin = archive_FilePartExtractionBegin; archive.CompressedBytesRead = archive_CompressedBytesRead; Task.Run(() => { long order = 0; foreach (var entry in archive.Entries) { if (!entry.IsDirectory) { entry.WriteToDirectory(destinationPath, new ExtractionOptions() { ExtractFullPath = true, Overwrite = true, }); } order ; this.CrossThreadCalls(() => { if (volumes > 1) { progress[0].Value = CreatePercentage(order, volumes); } }); } MessageBox.Show("解压缩任务完成 !"); }); } private void archive_EntryExtractionBegin(object sender, ArchiveExtractionEventArgs e) { entryTotal = e.Item.Size; info_builde1 = "提取文件: " e.Item.Key ";"; } private void archive_FilePartExtractionBegin(object sender, FilePartExtractionBeginEventArgs e) { partTotal = e.Size; info_builde2 = "分卷:" e.Name ";"; } private void archive_CompressedBytesRead(object sender, CompressedBytesReadEventArgs e) { string percentage = entryTotal.HasValue ? CreatePercentage(e.CompressedBytesRead, entryTotal.Value).ToString() : "Unknown"; info_builde = info_builde1 info_builde2 "字节:" e.CompressedBytesRead ";百分比:" percentage "%"; this.CrossThreadCalls(() => { compress_Info.Text = info_builde; progress[1].Value = int.Parse(percentage) > 100 || int.Parse(percentage) < 0 ? 100 : int.Parse(percentage); if (volumes < 2) progress[0].Value = progress[1].Value; Application.DoEvents(); }); } private int CreatePercentage(long n, long d) { return (int)(((double)n / (double)d) * 100); }
    2019-07-21下载
    积分:1
  • c# 压缩与压缩实例源码下载(可设置密码 加密压缩)
    可加密压缩,选择压缩文件 并设置压缩路径
    2015-03-14下载
    积分:1
  • 海康官方demo
    海康官方demo,包含操作文档
    2020-12-12下载
    积分:1
  • jquery.uploadify 上传实例源码下载
    Handler 里的文件 主要是创建文件夹 和文件用的.Upload 里的Index文件 是前台的调用 取你需要的UploadFile 我们这边是临时文件夹 上传成功 会吧文件删除 根据你的需求 不删就不用掉删除方法 DelFiles()uploadify 是他的源生js和css我们这边用的是MVC UploadController.cs 是控制器文件 里边有的方法是根据自己业务写的.UploadFileService 这个底层方法 里边有读取临时文件夹的 文档数据的方法 GetFileTempList()我把涉及到的 文件 都放进去了. 你可以根据代码看一下  这玩意我也没研究过 你先往你程序里套一下 哪不对咱在研究研究. 网络商场示例
    2015-01-27下载
    积分:1
  • C# 操作pdf电子书 源码下载
    实现功能如下: 1.构造函数2.私有字段3.设置字体4.设置页面大小5.实例化文档6.打开文档对象7.关闭打开的文档8.添加段落9.添加图片10.添加链接、点
    2013-09-04下载
    积分:1
  • C#json、导出一年的节假日信息获得一年内的365天
    【实例简介】好些时候需要获得中国的法定节假日信息,本例就是获得一个这样的excel
    2021-08-15 00:31:04下载
    积分:1
  • ITextSharp 生成PDF实例,实例中还包含调用模版生成Word功能 附完整源码
    压缩包中包含 ITextSharp中文教程用C#制作PDF文件全攻略.pdf 以及 用C#生成PDF文件、调用模版生成Word文档 等很多比较实用的实例,详见压缩包与截图,其中附完整源码
    2013-04-13下载
    积分:1
  • C#实现Word转RTF档实例
    C#实现Word转RTF文档功能
    2013-01-20下载
    积分:1
  • C# 读写excel表 例子源码下载
    C# 读写excel表 例子源码下载
    2014-11-04下载
    积分:1
  • 696516资源总数
  • 106914会员总数
  • 0今日下载