public AddDirectoryByName ( string directoryNameInArchive ) : |
||
directoryNameInArchive | string | /// The name of the directory to create in the archive. /// |
return |
using Ionic.Zip; // create a new zip archive using(var zip = new ZipFile()) { // add a directory named "myFolder" to the archive zip.AddDirectoryByName("myFolder"); // save the zip archive zip.Save("myArchive.zip"); }
using Ionic.Zip; // create a new zip archive using(var zip = new ZipFile()) { // add two directories to the archive zip.AddDirectoryByName("myFolder1"); zip.AddDirectoryByName("myFolder2"); // save the zip archive zip.Save("myArchive.zip"); }In this example, we add two directories named "myFolder1" and "myFolder2" to the zip archive. We then save the zip archive to a file named "myArchive.zip". Package Library: This code uses the Ionic.Zip package library for zipping and unzipping files in C# applications.
Use this when you want to create a directory in the archive but there is no corresponding filesystem representation for that directory.
You will probably not need to do this in your code. One of the only times you will want to do this is if you want an empty directory in the zip archive. The reason: if you add a file to a zip archive that is stored within a multi-level directory, all of the directory tree is implicitly created in the zip archive.
public AddDirectoryByName ( string directoryNameInArchive ) : |
||
directoryNameInArchive | string | /// The name of the directory to create in the archive. /// |
return |