I have a directory that contains several files. I want compress this folder to a zip or tar.gz file. How can I do his work in C#?
The question is quite old and so are the answers.
Best answer since end of 2012 is: Use .NET 4.5 and the contained System.IO.Compression
and System.IO.Compression.ZipArchive
namespace classes.
One of many example links you receive if you search in the internet: http://www.codeproject.com/Articles/381661/Creating-Zip-Files-Easily-in-NET
Since 2014/2015 ff.: With Roslyn the whole framework library was published as Open Source, so AFAI understand it, you are free to extract the code from the 4.5 classes (as it should be not really system specific) and use it as a library for the earlier .NET frameworks. Maybe this would give some license advantages over using the other classes- but this has to be analyzed by you.