What is an example (simple code) of how to zip a folder in C#?
Update:
I do not see namespace ICSharpCode
. I downloaded ICSharpCode.SharpZipLib.dll
but I do not know where to copy that DLL file. What do I need to do to see this namespace?
And do you have link for that MSDN example for compress folder, because I read all MSDN but I couldn't find anything.
OK, but I need next information.
Where should I copy ICSharpCode.SharpZipLib.dll
to see that namespace in Visual Studio?
Following code uses a third-party ZIP component from Rebex:
Or if you want to add more folders without need to open and close archive multiple times:
You can download the ZIP component here.
Using a free, LGPL licensed SharpZipLib is a common alternative.
Disclaimer: I work for Rebex
"Where should I copy ICSharpCode.SharpZipLib.dll to see that namespace in Visual Studio?"
You need to add the dll file as a reference in your project. Right click on References in the Solution Explorer->Add Reference->Browse and then select the dll.
Finally you'll need to add it as a using statement in whatever files you want to use it in.
using DotNetZip (available as nuget package):
Usage:
Or
ComponentPro ZIP can help you achieve that task. The following code snippet compress files and dirs in a folder. You can use wilcard mask as well.
http://www.componentpro.com/doc/zip has more examples