如何使用SharpZipLib从zip文件中提取文件夹? [英] How to extract a folder from zip file using SharpZipLib?

查看:40
本文介绍了如何使用SharpZipLib从zip文件中提取文件夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 test.zip 文件,其中包含一个文件夹,其中包含一堆其他文件和文件夹.

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

我发现 SharpZipLib 后发现 .gz/GzipStream 不是要走的路,因为它只适用于个别文件.更重要的是,这样做类似于使用 GZipStream 意味着它将创建一个文件.但我已经压缩了整个文件夹.如何解压到

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

出于某种原因,此处的解压示例设置为忽略目录,所以我不完全确定这是如何完成的.

For some reason the example unzipping here is set to ignore directories, so I'm not totally sure how that is done.

此外,我需要使用 .NET 2.0 来完成此操作.

Also, I need to use .NET 2.0 for accomplish this.

推荐答案

我认为这是更简单的方法.默认功能(请在此处查看更多信息 https://github.com/icsharpcode/SharpZipLib/wiki/FastZip)

I think it is the easier way. Default functionality (please look here for more info 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);

这篇关于如何使用SharpZipLib从zip文件中提取文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆