Thursday, May 26, 2016

Code snippet: Unzip the zip file in C# using DotNetZip

DotNetZip is a FAST, FREE class library and toolset for manipulating zip files. Use VB, C# or any .NET language to easily create, extract, or update zip files.

1:  public static void DeCompressFile(string zipFilePath, string extractPath)  
2:      {  
3:        string zipToUnpack = zipFilePath;  
4:        string unpackDirectory = extractPath;  
5:        using (ZipFile zipfiles = ZipFile.Read(zipToUnpack))  
6:        {  
7:          // Here, we extract every entry, but we could extract conditionally based on entry name, size, date, checkbox status, etc.   
8:          foreach (ZipEntry e in zipfiles)  
9:          {  
10:            e.Extract(unpackDirectory, ExtractExistingFileAction.OverwriteSilently);  
11:          }  
12:        }  
13:    
14:        Console.WriteLine("Status: Done extracting the zipped Archive");  
15:      }   

C#

0 comments :

Post a Comment

 

© 2011 GIS and Remote Sensing Tools, Tips and more .. ToS | Privacy Policy | Sitemap

About Me