如何使用sharpziplib 从zip文件解压文件夹?

.Net技术 码拜 6年前 (2015-07-02) 1097次浏览 0个评论

I have a test.zip file which contains inside a Folder with a bunch of other files and folders in it.

我有一个test.zip,里面的文件夹包含很多其他的文件和文件夹。

I found SharpZipLib after figuring out that .gz / GzipStream was not the way to go since its only for individual files. More importantly, doing this is similar to using GZipStream meaning it will create a FILE. But I have whole folder zipped. How do I unzip to a
通过查找,我发现sharpziplib .gz/ gzipstream是行不通的,因为它只针对单个文件。更重要的是,这样使用gzipstream意味着它将创建一个文件。但我有整个文件夹压缩。我该怎么解压

For some reason the example unzipping here is set to ignore directories, so I’m not totally sure how that is done.
由于某些原因,解压缩示例忽略了目录,所以我不确定如何做的。

Also, I need to use .NET 2.0 for accomplish this.
还有,我要用.NET 2.0 实现。


这是很简单的. 默认功能 (你可以从这里获取更多信息

https://github.com/icsharpcode/SharpZipLib/wiki/FastZip)

如下是解压文件夹代码:

using System;
using ICSharpCode.SharpZipLib.Zip;

var zipFileName = @"T:\Temp\Libs\SharpZipLib_0860_Bin.zip";
var targetDir = @"T:\Temp\Libs\unpack";
FastZip fastZip = new FastZip();
string fileFilter = null;

// Will always overwrite if target filenames already exist
fastZip.ExtractZip(zipFileName, targetDir, fileFilter);

 


CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明如何使用sharpziplib 从zip文件解压文件夹?
喜欢 (0)
[1034331897@qq.com]
分享 (0)

文章评论已关闭!