The inbuilt Compression class GzipStream class(System.IO.Compression) for C# does not provide the ability to compress all the files within a folder.You can do this by just few lines of code and just forgetting the techinical aspects behind it by using DotNetZip(Ioniczip).DotNetZip is a free class library that can be used for creating and editing zip files.
The project is Hosted at CodePlex check out http://dotnetzip.codeplex.com
To use DotNetZip Library in your C# Project follow these steps
The project is Hosted at CodePlex check out http://dotnetzip.codeplex.com
To use DotNetZip Library in your C# Project follow these steps
- Download the latest release from http://dotnetzip.codeplex.com/releases/
- Add a Reference to DotNetZip from your project by going to Project> Add Reference .Browse for Ionic.Zip.dll in the release that you have downloaded.
- Then add the reference in your project by adding the statement 'using Ionic.Zip'
- Then use the code given below to create a zip file from a folder
using (ZipFile zip = new ZipFile())
{
zip.AddDirectory(@"thefoldertoadd");
zip.Save("pathToSaveZipFile");
}
No comments:
Post a Comment