Extract Zip File By Using SharpZipLib Library in ASP.NET
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:
Working sample of this ExtractZip class can be downloaded via here.