How to UnZip files in ASP.NET?

In this article I am going to explain about how to Unzip zip files through ASP.NET. I have used Ionic.Zip dll to extract that zip files into normal files.

Description :

In my previous articles I was explained in detailed about how to create zip files in windows and web applications.

Zip file in ASP.NET

Zip file in C#.NET

Here I am going to explain how to extract that zip files in to normal files using ASP.NET . Two ways I am extract zip file

1) Fully extract all files in to destination folder

2) Extract only jpg files in to destination folder

Server side

I have statically mentioned source zip folder path and destination folder path etc.

using Ionic.Zip;
using System.IO;

public partial class _Default : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)

//UnZip Process
protected void BtnUnzip_Click(object sender, EventArgs e)
//source location of zip file
string sourceLocation = "D:\\";
//After extract where placed that files
string destLocation = "D:\\destfolder";
//Conditional extract and placed in this folder
string CondFiles = "D:\\condfolder";

//Extract all files in the zip file
using (ZipFile zip1 = ZipFile.Read(sourceLocation))
//Full file extract code
foreach (ZipEntry e1 in zip1)
e1.Extract(destLocation, ExtractExistingFileAction.OverwriteSilently);
//Based on the conditions to extract
foreach (ZipEntry e2 in zip1)
//Extract only txt files in extract folder
if (e2.FileName.ToString().Substring((e2.FileName.LastIndexOf('.') + 1), (e2.FileName.ToString().Length - e2.FileName.LastIndexOf('.') - 1)) == "jpg")
e2.Extract(CondFiles, ExtractExistingFileAction.OverwriteSilently);

Source code:

Client Side: ASP.NET
Code Behind: C#


I hope this code snippet is help you to know about unzip zip files through ASP.NET.


  • UnZip_Source (43965-73836-UnZip-Source.rar)
  • Comments

    Author: Fajar21 Jul 2012 Member Level: Bronze   Points : 0

    thank info

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: