.NET 压缩解压库发布,支持进度查看

刚发布了一个 .net压缩解压库,基于SharpZipLib开发 ,支持进度查看,支持路径保持与否。

CL.IO.Zip 是一个基于SharpZipLib的一个压缩和解压的类库,提供给用户在.net环境下使用(VB.NET,C#..等等)当前最新版本为:V1.1.0

github地址:https://github.com/Jarvin-Guan/CL.IO.Zip    标个星

目前版本:v1.1.0。

百度网盘下载地址:http://pan.baidu.com/s/1qWwZ0LI

由云梯工作室提供。欢迎各位自由下载源码,自由使用,2015-6-15。

 

CL.IO.Zip

    CL.IO.Zip 是一个基于SharpZipLib的一个压缩和解压的类库,提供给用户在.net环境下使用(VB.NET,C#..等等)当前最新版本为:V1.1.0


    做任何操作之前,请使用单例模式,获取ZipHandler对象。

    ZipHandler handler = ZipHandler.GetInstance();

1.压缩

    1.1压缩文件夹,并获取压缩进度。

Method:PackDirectory

    public void PackDirectory(string strDirectory, string zipedFile, ProcessChange changedDG)

Demo

    var fromDic="E:\ZipTest";\\需要压缩的文件夹路径

    var toZip="E:\ZipFile.zip";\\生成压缩包的目标路径

    handler.PackDirectory(fromDic, toZip, (num) => { Debug.WriteLine("pack num:" + num); });\\num为百分比,最大为100,可在此处写处理逻辑 

    1.2添加文件到zip文件中。

Method:AddFile

    public void AddFile(string filePath, string zipPath,string filePathInZip)

Demo

    var filePath="E:\ReadyToAdd.txt";\\需要添加到压缩包的文件路径

    var zipPath="E:\ZipFile.zip";\\压缩包文件路径

    handler.AddFile(filePath, zipPath, @"123\" + Path.GetFileName(filePath));\\需要添加到压缩包的文件路径 

    1.3添加文件夹到zip文件中(此函数支持是否保存文件路径的格式。)

Method:AddDirectory

    public void AddDirectory(string dicPath,string zipPath,string dicPathInZip,ProcessChange changedDG)

Demo

    var dicPath="E:\ReadyToAddDic";\\需要添加到压缩包的文件夹路径

    var zipPath="E:\ZipFile.zip";\\压缩包文件路径

    var dicPathInZip="ReadyToAddDic";\\需要压缩到压缩包内的相对路径,当前值指的是根目录的ReadyToAddDic

    handler.IsKeepPath=true;\\保存原路径

    handler.AddDirectory(dicPath, zipPath, dicPathInZip,(num) => { Debug.WriteLine("压缩进度:" + num); }); 

2.解压

    2.1对压缩包进行解压。

Method:UnpackAll

     public void UnpackAll(string zipFilePath, string unzipPath, ProcessChange changedDG)

Demo

    var fromZip="E:\ZipTest.zip";\\需要解压的压缩文件路径

    var toDic="E:\ZipFile";\\解压到的文件夹路径

    handler.UnpackAll(fromZip, toDic, (num) => { Debug.WriteLine("解压进度:" + num); }); 

    2.2解压压缩包内的指定文件。

Method:UnpackFile

    public void UnpackFile(string zipFilePath,string unzipPath,string filePathInZip)

Demo

    var fromZip="E:\ZipFile.zip";

    var toDic="E:\UnZipTest";

    handler.UnpackFile(fromZip, toDic, @"models/db.js"); 

    2.3解压压缩包内的指定文件夹。

Method:UnpackDirectory

    public void UnpackDirectory(string zipFilePath, string unzipPath, string DicPathInZip)

Demo

    var fromZip="E:\ZipFile.zip";\\压缩包文件路径

    var toDic="E:\UnZipTest";

    var dicPathInZip="node_modules"; 

    handler.IsKeepPath=true;\\保存原路径

    handler.UnpackDirectory(fromZip, toDic, dicPathInZip);

posted @ 2015-06-16 12:24  ♂立地←  阅读(4409)  评论(8编辑  收藏  举报