Extract a ZIP file programmatically by DotNetZip library?

You need to test each ZipEntry to see if you want to extract it: public void ExtractFileToDirectory(string zipFileName, string outputDirectory) { ZipFile zip = ZipFile.Read(zipFileName); Directory.CreateDirectory(outputDirectory); foreach (ZipEntry e in zip) { // check if you want to extract e or not if(e.FileName == “TheFileToExtract”) e.Extract(outputDirectory, ExtractExistingFileAction.OverwriteSilently); } }

Creating Zip file from stream and downloading it

2 things. First, if you keep the code design you have, you need to perform a Seek() on the MemoryStream before writing it into the entry. dt.TableName = “Declaration”; MemoryStream stream = new MemoryStream(); dt.WriteXml(stream); stream.Seek(0,SeekOrigin.Begin); // <– must do this after writing the stream! using (ZipFile zipFile = new ZipFile()) { zipFile.AddEntry(“Report.xml”, “”, stream); … Read more

tech