Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If you are manipulating ZIP files, you may want to look into a 3rd-party library to help you.</p> <p>For example, DotNetZip, which has been recently updated. The current version is now v1.8. Here's an example to create a zip:</p> <pre><code>using (ZipFile zip = new ZipFile()) { zip.AddFile("c:\\photos\\personal\\7440-N49th.png"); zip.AddFile("c:\\Desktop\\2005_Annual_Report.pdf"); zip.AddFile("ReadMe.txt"); zip.Save("Archive.zip"); } </code></pre> <p>Here's an example to <em>update</em> an existing zip; you don't need to extract the files to do it:</p> <pre><code>using (ZipFile zip = ZipFile.Read("ExistingArchive.zip")) { // 1. remove an entry, given the name zip.RemoveEntry("README.txt"); // 2. Update an existing entry, with content from the filesystem zip.UpdateItem("Portfolio.doc"); // 3. modify the filename of an existing entry // (rename it and move it to a sub directory) ZipEntry e = zip["Table1.jpg"]; e.FileName = "images/Figure1.jpg"; // 4. insert or modify the comment on the zip archive zip.Comment = "This zip archive was updated " + System.DateTime.ToString("G"); // 5. finally, save the modified archive zip.Save(); } </code></pre> <p>here's an example that extracts entries:</p> <pre><code>using (ZipFile zip = ZipFile.Read("ExistingZipFile.zip")) { foreach (ZipEntry e in zip) { e.Extract(TargetDirectory, true); // true =&gt; overwrite existing files } } </code></pre> <p>DotNetZip supports multi-byte chars in filenames, Zip encryption, AES encryption, streams, Unicode, self-extracting archives. Also does ZIP64, for file lengths greater than 0xFFFFFFFF, or for archives with more than 65535 entries.</p> <p>free. open source</p> <p>get it at <a href="https://archive.codeplex.com/?p=dotnetzip" rel="nofollow noreferrer">codeplex</a> or <a href="https://codeplexarchive.blob.core.windows.net/archive/projects/DotNetZip/DotNetZip.zip" rel="nofollow noreferrer">direct download from windows.net</a> - CodePlex has been discontinued and archived</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload