Ionic Zip Library v1.9.1.6
AddSelectedFiles Method (selectionCriteria, directoryOnDisk, directoryPathInArchive, recurseDirectories)
Adds to the ZipFile a selection of files from the specified directory on
disk, that conform to the specified criteria, optionally recursing through
subdirectories, and using a specified root path for entries added to the
zip archive.
Declaration Syntax
C# | Visual Basic | Visual C++ |
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.
- recurseDirectories (Boolean)
- If true, the method also scans subdirectories for files matching the criteria.
Remarks
This method selects files from the specified disk directory that match the
specified selection criteria, and adds those files to the ZipFile, using
the specified directory path in the archive. If recurseDirectories
is true, files are also selected from subdirectories, and the directory
structure in the filesystem is reproduced in the zip archive, rooted at
the directory specified by directoryOnDisk. For details on the
syntax for the selectionCriteria parameter, see AddSelectedFiles(String).
Examples
This example zips up all files that are NOT *.pst files, in the current
working directory and any subdirectories.
CopyC#
using (ZipFile zip = new ZipFile()) { zip.AddSelectedFiles("name != *.pst", SourceDirectory, "backup", true); zip.Save(PathToZipArchive); }
CopyVB.NET
Using zip As ZipFile = New ZipFile zip.AddSelectedFiles("name != *.pst", SourceDirectory, "backup", true) zip.Save(PathToZipArchive) End Using