Personal Blog of Mustafa Basgun

Extract Zip File By Using SharpZipLib Library in ASP.NET

with 5 comments

If you are developing an IO style application, it is a high possibility that one of the requirements would ask you a utility to extract an uploaded zip file. Well, here is a one way to accomplish this with VB.NET by using the SharpLibZip library.

After downloading the appropriate binary file and placing it to the Bin directory of your project, let’s have the webform similar to the following:

HTML presentation of this webform should look like:

Click event of Button1 is the one using the ExtractZip class:

Now, time to delve into the ExtractZip class! Code speaks pretty well for itself, therefore I will not be putting detailed description. Parameters are:

Before jumping into the extraction, it would be a good practice to perform some simple checks:

And, the Try Catch statement doing the main job is:

Delete the original zip file if the optional DeleteZip parameter was left as True:

Download

Working sample of this ExtractZip class can be downloaded via here.

Advertisements

Written by Mustafa Basgun

February 8, 2008 at 5:00 PM

5 Responses

Subscribe to comments with RSS.

  1. Brilliant.

    Jack

    July 3, 2008 at 5:04 AM

  2. Thanks, I will be using this.

    Sykespro

    November 6, 2008 at 5:08 PM

  3. Excellent.

    Vikas Kantawala

    April 7, 2009 at 6:28 AM

  4. If zip file is large, it could take a long time. User will have to wait until it finishes to unzip. Is there an asynchronous way to do this? Using threading or window service?

    john

    May 14, 2009 at 10:07 AM

  5. Thanks a billion!

    Klaas

    September 20, 2011 at 4:50 PM


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: