Ionic Zip Library v1.9.1.6
AddSelectedFiles Method (selectionCriteria, directoryOnDisk, directoryPathInArchive)
Adds to the ZipFile a selection of files from the specified directory on
disk, that conform to the specified criteria, and using a specified root
path for entries added to the zip archive.
Declaration Syntax
Parameters
- selectionCriteria (String)
- The criteria for selection of files to add to the ZipFile.
- directoryOnDisk (String)
- The path to the directory in the filesystem from which to select files.
- directoryPathInArchive (String)
- Specifies a directory path to use to in place of the directoryOnDisk. This path may, or may not, correspond to a real directory in the current filesystem. If the files within the zip are later extracted, this is the path used for the extracted file. Passing null (nothing in VB) will use the path on the file name, if any; in other words it would use directoryOnDisk, plus any subdirectory. Passing the empty string ("") will insert the item at the root path within the archive.
Remarks
This method selects files from the specified disk directory matching the specified selection criteria, and adds those files to the ZipFile, using the specified directory path in the archive. The search does not recurse into subdirectories. For details on the syntax for the selectionCriteria parameter, see AddSelectedFiles(String).
Examples
This example zips up all *.psd files in the "photos" directory that have
been saved since 2009 February 14th, and puts them all in a zip file,
using the directory name of "content" in the zip archive itself. When the
zip archive is unzipped, the folder containing the .psd files will be
named "content".
CopyC#
using (ZipFile zip = new ZipFile()) { // Use a compound expression in the selectionCriteria string. zip.AddSelectedFiles("name = *.psd and mtime > 2009-02-14", "photos", "content"); zip.Save(PathToZipArchive); }
CopyVB.NET
Using zip As ZipFile = New ZipFile zip.AddSelectedFiles("name = *.psd and mtime > 2009-02-14", "photos", "content") zip.Save(PathToZipArchive) End Using