Click here to Skip to main content
15,899,025 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello.. I have to write code for unzipping the already zipped folder(.zip file) in asp.net web application. Please Help me.
Posted
Updated 2-Dec-10 21:45pm
v2

First, you have to find the format of the zipped file, say .zip or rar.

And to unzip Have a look
 
Share this answer
 
Comments
Dalek Dave 3-Dec-10 4:14am    
Good answer.
Ksmita 7-Dec-10 6:16am    
Its not working :(
Hi,
you can use this function

public void ExtractArchive(string zipFilename, string ExtractDir)
{
int Redo = 1;
ZipInputStream MyZipInputStream = default(ZipInputStream);
FileStream MyFileStream = default(FileStream);
MyZipInputStream = new ZipInputStream(new FileStream(zipFilename, FileMode.Open, FileAccess.Read));
ZipEntry MyZipEntry = MyZipInputStream.GetNextEntry();
Directory.CreateDirectory(ExtractDir);
while ((MyZipEntry != null))
{
if ((MyZipEntry.IsDirectory))
{
Directory.CreateDirectory(ExtractDir + "\\" + MyZipEntry.Name);
}
else
{
if (!Directory.Exists(ExtractDir + "\\" + Path.GetDirectoryName(MyZipEntry.Name)))
{
Directory.CreateDirectory(ExtractDir + "\\" + Path.GetDirectoryName(MyZipEntry.Name));
}
MyFileStream = new FileStream(ExtractDir + "\\" + MyZipEntry.Name, FileMode.OpenOrCreate, FileAccess.Write);
int count = 0;
byte[] buffer = new byte[4097];
count = MyZipInputStream.Read(buffer, 0, 4096);
while (count > 0)
{
MyFileStream.Write(buffer, 0, count);
count = MyZipInputStream.Read(buffer, 0, 4096);
}
MyFileStream.Close();
}
try
{
MyZipEntry = MyZipInputStream.GetNextEntry();
}
catch (Exception ex)
{
MyZipEntry = null;
}
}
if ((MyZipInputStream != null))
MyZipInputStream.Close();
if ((MyFileStream != null))
MyFileStream.Close();
}
 
Share this answer
 
Comments
Omid Reza Aryafar 14-Feb-13 11:54am    
tnx a lot.
but what are ZipInputStream and ZipEntry?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900