create zip file in .net with password
Take a look at DotNetZip (@AFract supplied a new link to GitHub in the comments) It has got pretty geat documentation and it also allow you to load the dll at runtime as an embeded file.
Take a look at DotNetZip (@AFract supplied a new link to GitHub in the comments) It has got pretty geat documentation and it also allow you to load the dll at runtime as an embeded file.
First thing you’d always want to do when searching for the reason why software fails is locating the source of the error message. You do that by using Google first. Second hit (right now) is golden, somebody has decompiled Windows executables and located this specific string as resource ID #10209 in a file named zipfldr.dll … Read more
How about just: zip.AddFile(file,””); or zip.AddFile(file,@”\”);
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); } }
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