Zip/Unzip files in C#

DotNetZip is an OpenSource Zip library for C#

public void ZipDir(string directoryPath, string zipFilePath)
{
  using(ZipFile zip = new ZipFile())
  {
    zip.AddDirectory(directoryPath);
    zip.Save(zipFilePath);
  }            
}
public void UnzipDir(string zipFilePath, string directoryPath)
{
  using(ZipFile zip = ZipFile.Read(zipFilePath))
  {                                
    zip.ExtractAll(directoryPath,true);                
  }            
}
public void UnzipFile(string zipFilePath, string directoryPath, string fileName)
{
  using (ZipFile zip = ZipFile.Read(zipFilePath))
  {
    zip.Extract(fileName, directoryPath, true);
  }
}

Comments

Popular posts from this blog

Tibco Rendezvous (tibrv) C# .Net example

Parse XML to dynamic object in C#