<img alt="" src="https://secure.leadforensics.com/150446.png " style="display:none;">

Blogs

Compression and Decompression of files using Ionic DLL

Compression and Decompression of files using Ionic DLL.jpg

There are many scenarios in which we need to deal with zip and unzip. This will decrease our manual work of zipping and unzipping. Using this, we can make automated processes for the same. .NET has vast improvement in the using System.IO.Compression; namespace. This includes below types to compress and decompress files and streams.

  • ZipFile
  • ZipArchive
  • ZipArchiveEntry
Using these types we can also read and modify the contents of compressed file. We can easily zip and unzip files in .net.

  • Zip

First we see for zipping a folder including subfolder or files. Here, we just call the CreateFromDirectory() method of ZipFile.We can also use CreateDirectory(), GetDirectory() methods of ZipArchive class and Open() and Delete() methods of ZipArchiveEntry class

ZipFile.CreateFromDirectory(@"D:\Test\Sample", @"C:\Temp\zipfiles.zip");

Explanation: Note that here we simply provide two parameters to method. First is, what to zip and second is where to put it. By default method considers that level of compression is optimal, we are not providing that here. Other levels are fastest and none.

Topics: DLL

e-Zest is a leading digital innovation partner for enterprises and technology companies that utilizes emerging technologies for creating engaging customers experiences. Being a customer-focused and technology-driven company, it always helps clients in crafting holistic business value for their software development efforts. It offers software development and consulting services for cloud computing, enterprise mobility, big data and analytics, user experience and digital commerce.