Which method do you think is the \"best\".
System.IO.Packaging
namespace?I realise that this is an old question now, but I just thought I'd add a more up to date answer. If you are using .NET 4.5, then you can programmatically save multiple files into a zip folder easily using the new built in ZipFile class.
First, you'll need to prepare your files into a new folder (Directory.CreateDirectory
, File.Move
) and then you can simply use the ZipFile.CreateFromDirectory Method (adapted from the linked page):
string filePathOfNewFolder = @"c:\example\start";
string zipFilePath = @"c:\example\result.zip";
ZipFile.CreateFromDirectory(filePathOfNewFolder, zipFilePath);
I've found the DotNetZip Library to be this easiest way to work with zip files. SharpZipLib is a far more powerful and flexible solution.