Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to extract a folder from zip file using SharpZipLib?

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

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.

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

like image 887
dsp_099 Avatar asked Mar 16 '14 22:03

dsp_099


Video Answer


1 Answers

I think it is the easier way. Default functionality (please look here for more info https://github.com/icsharpcode/SharpZipLib/wiki/FastZip)

it extract with folders.

code:

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);
like image 128
Alexander V. Avatar answered Sep 28 '22 21:09

Alexander V.