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:      }   

Comments

Popular posts from this blog

Prevent WPF Global Keyboard Hook from stops working after hitting keys a while C# .NET

Generate ArcGIS Token By URL Request From ArcGIS Portal, Federated Environment , ESRI JS API and Angular snippets

Solution: IntelliJ not recognizing a particular file correctly, instead its stuck as a text file