Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

I want to compress a folder as .zip using asp.net. I have a folder contains images in my website. Now i need to compressed it (ZIP) to take backup of that folder. So the user can download it from server in the format of zip file.

how to make ZIP folder using ASP.NET.

any help ?

Thanks in Advance
Posted
Updated 14-Jun-11 0:08am
v2

ASP.NET can't compress zips. It's an engine for generating HTML. C# and VB.NET can't do it without some sort of add in library. But, J# can do it, there's tons of articles on how to use J# and you could use a J# library to do it in C# or VB.NET, if you're in ASP.NET nor not.
 
Share this answer
 
Hi,

You can check these solutions
http://forums.asp.net/t/1193746.aspx[^]
http://weblogs.asp.net/jgalloway/archive/2007/10/25/creating-zip-archives-in-net-without-an-external-library-like-sharpziplib.aspx[^]
http://www.eggheadcafe.com/articles/20050821.asp[^]
For each of the solutions there is a function that needed to invoke from your web application, like if you use .NET Zip Library you have to use this code below
ZipFile zip= new ZipFile("MyNewZip.zip"); 
zip.AddDirectory("My Pictures", true); // AddDirectory recurses subdirectories
zip.Save(); 

Hope this will help.
 
Share this answer
 
ICSHARPziplib library helps you to zip a folder and download it.
go through following link which will help you to zip your folder

ZIP ME[^]

and then use following code to download folder

if (File.Exists(szFilePath))
            {
                HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + fInfo.Name);

                HttpContext.Current.Response.AddHeader("Content-Length", fInfo.Length.ToString());
                HttpContext.Current.Response.ContentType = "application/zip";

                HttpContext.Current.Response.TransmitFile(fInfo.FullName);

                HttpContext.Current.Response.End();
                return true;
            }
 
Share this answer
 
v2
 
Share this answer
 
Comments
vikash kumar NIIT 20-Jan-13 0:25am    
HI,

this link is worked for me
thanks
Uday P.Singh 21-Jan-13 8:52am    
glad to know it works!

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