Click here to Skip to main content
15,892,768 members
Please Sign up or sign in to vote.
2.00/5 (3 votes)
See more:
Hello,

I have searched the net for a code that would zip not just the files from a specified folder but the whole folder. I found many example but non of them is doing what I need. Others that could probably do the job I am unalbe to run - example DotNetZipFiles

Could anybody help me with that please. I need the same result as I am right cliking a folder and send to a commpressed folder.

I would be happy for a solution either in C# or VB.Net

Thanks
B
Posted
Updated 20-Dec-11 11:18am
v4
Comments
Sergey Alexandrovich Kryukov 10-Dec-11 17:40pm    
So C++ or VB.NET? Do you mean C++/CLI? In this case, change the tag.
--SA

Is Google your enemy? Here is one of the answers: http://stackoverflow.com/questions/905654/zip-folder-in-c-sharp[^].

I think all you need to do it in .NET is using SharpZipLib, http://www.icsharpcode.net/OpenSource/SharpZipLib/[^].

—SA
 
Share this answer
 
v2
Sorry guys, I cant make it to work. Most of the solutios that you have proposed I was previously able to find and test but probably I am doing something wrong. I am new to C#.

I downloaded the following example http://geraldgibson.net/dnn/Home/CZipFileCompression/tabid/148/Default.aspx[^]

but when I run it it zips only one file from the specified folder. Could anybody help me with this specific exmample? Are you able to sucesfully run it and zip a whole folder?

Thanks in advance!
B
 
Share this answer
 
Comments
RaviRanjanKr 11-Dec-11 3:50am    
A suggestion :- you can use Have a question or Comment button to drop your message and to get Immediate response instead of posting as answer.
I also tried http://forums.digitalpoint.com/showthread.php?t=674969[^]

as a solution for VB.Net but cant make the reference to the vsjlib library. Could anybody tell me how could I find this library?

Thanks
B
 
Share this answer
 
That is how I solved my problem in VB.NET(using the free DotNetZip Library from here :http://dotnetzip.codeplex.com/[^]

For me it was hard to get the code working as VB.NET is something new for me. However, I hope that this will help others.

VB
Imports System.IO
Imports Ionic.Zip
**********************

zipFileName = TemporaryFolder & FileName_TemporaryFolder & ".zip"
Using zip As Ionic.Zip.ZipFile = New Ionic.Zip.ZipFile
zip.AddDirectory(ArchiveFolder & sYear & sMonth & sDay & "\" & FileName_TemporaryFolder, FileName_TemporaryFolder)
zip.Save(zipFileName)
End Using
 
Share this answer
 

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


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