Im developing a c# application which has to zip all the content within a directory.. Is this possible?
thanks
Im developing a c# application which has to zip all the content within a directory.. Is this possible?
thanks
Yes you can.DotNetZip supports adding a Directory to a zip file with the ZipFile.AddDirectory()
methods.
To zip up an entire directory, recursively:
using (ZipFile zip = new ZipFile())
{
zip.UseUnicode= true; // utf-8
zip.AddDirectory(@"MyFile");
zip.Save(ZipFileToCreate);
}
See the documentation for class ZipFile
at http://msdn.microsoft.com/en-us/library/system.io.compression.zipfile(v=vs.110).aspx.
UPDATE: This class is only available in .NET 4.5, which is not installed as part of Windows 7. You would have to download it from Microsoft.
You can use also SevenZipSharp like so:
SevenZipCompressor compressor = new SevenZipCompressor();
compressor.CompressDirectory(...);