I don’t think you can fasten the entire folder with System.IO.Compression, you can only compress files inside the folder. Instead, you can use DotNetZip. This is a 100% managed code library that can be used in any .NET application - Console, Winforms, WPF, ASP.NET, Sharepoint, web services applications, etc.
Download the developer package from http://dotnetzip.codeplex.com/Release/ProjectReleases.aspx .
, DotNetZip DLL , :
string[] MainDirs = Directory.GetDirectories(""c:\users\public\reports");
for (int i = 0; i < MainDirs.Length; i++)
{
using (ZipFile zip = new ZipFile())
{
zip.UseUnicodeAsNecessary = true;
zip.AddDirectory(MainDirs[i]);
zip.CompressionLevel = Ionic.Zlib.CompressionLevel.BestCompression;
zip.Comment = "This zip was created at " + System.DateTime.Now.ToString("G");
zip.Save(string.Format("test{0}.zip", i));
}
}
, ,