Skip to content

CL.IO.Zip(v1.1.0) is a Zip library written in C# for the .NET platform. it provide process delegate.

Notifications You must be signed in to change notification settings

Jarvin-Guan/CL.IO.Zip

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CL.IO.Zip

####    CL.IO.Zip 是一个基于SharpZipLib的一个压缩和解压的类库,提供给用户在.net环境下使用(VB.NET,C#..等等)当前最新版本为:V1.1.0 百度网盘下载地址:http://pan.baidu.com/s/1qWwZ0LI


    做任何操作之前,请使用单例模式,获取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);

About

CL.IO.Zip(v1.1.0) is a Zip library written in C# for the .NET platform. it provide process delegate.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages