Zip folder in C#

archive, c#, compression, directory, zip

Solution

This answer changes with .NET 4.5. Creating a zip file becomes incredibly easy. No third-party libraries will be required.

string startPath = @"c:\example\start";
string zipPath = @"c:\example\result.zip";
string extractPath = @"c:\example\extract";

ZipFile.CreateFromDirectory(startPath, zipPath);
ZipFile.ExtractToDirectory(zipPath, extractPath);

Problem

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?

Original source

Related problems