AddSelectedFiles Method (selectionCriteria, directoryOnDisk, directoryPathInArchive, recurseDirectories)

DotNetZip

Ionic Zip Library v1.9.1.6 AddSelectedFiles Method (selectionCriteria, directoryOnDisk, directoryPathInArchive, recurseDirectories)
ReferenceIonic.ZipZipFileAddSelectedFiles(String, String, String, Boolean)
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++
public void AddSelectedFiles(
	string selectionCriteria,
	string directoryOnDisk,
	string directoryPathInArchive,
	bool recurseDirectories
)
Public Sub AddSelectedFiles ( _
	selectionCriteria As String, _
	directoryOnDisk As String, _
	directoryPathInArchive As String, _
	recurseDirectories As Boolean _
)
public:
void AddSelectedFiles(
	String^ selectionCriteria, 
	String^ directoryOnDisk, 
	String^ directoryPathInArchive, 
	bool recurseDirectories
)
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

Assembly: Ionic.Zip (Module: Ionic.Zip) Version: 1.9.1.8 (1.9.1.8)