I have a case, where I need to extract Zip file with C# Ionic.zip library. Zip file contains multiple folders and I want to extract and copy a particular folder to specific destination.
e.g. Zip file named as abc.zip and directory structure will be like
Parent Directory->Sub directory 1->file a, file b Parent Directory->Sub directory 2->file c, file d
I just want to copy Sub Directory 1, how can I accomplish this task?
var existingZipFile = "name of the file.zip";
var targetDirectory = "name of the folder";
using (ZipFile zip = ZipFile.Read(existingZipFile))
{
foreach (ZipEntry e in zip.Where(x => x.FileName.StartsWith("Sub directory 1")))
{
e.Extract(targetDirectory);
}
}