AddSelectedFiles Method (selectionCriteria, recurseDirectories)

DotNetZip

Ionic Zip Library v1.9.1.6 AddSelectedFiles Method (selectionCriteria, recurseDirectories)
ReferenceIonic.ZipZipFileAddSelectedFiles(String, Boolean)
Adds to the ZipFile a set of files from the disk that conform to the specified criteria, optionally recursing into subdirectories.
Declaration Syntax
C# Visual Basic Visual C++
public void AddSelectedFiles(
	string selectionCriteria,
	bool recurseDirectories
)
Public Sub AddSelectedFiles ( _
	selectionCriteria As String, _
	recurseDirectories As Boolean _
)
public:
void AddSelectedFiles(
	String^ selectionCriteria, 
	bool recurseDirectories
)
Parameters
selectionCriteria (String)
The criteria for file selection
recurseDirectories (Boolean)
If true, the file selection will recurse into subdirectories.
Remarks

This method selects files from the the current working directory matching the specified criteria, and adds them to the ZipFile. 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 current working directory.

Using this method, the full path of the selected files is included in the entries added into the zip archive. If you don't want this behavior, use one of the overloads of this method that allows the specification of a directoryInArchive.

For details on the syntax for the selectionCriteria parameter, see AddSelectedFiles(String).

Examples
This example zips up all *.xml files in the current working directory, or any subdirectory, that are larger than 1mb.
CopyC#
using (ZipFile zip = new ZipFile())
{
    // Use a compound expression in the selectionCriteria string.
    zip.AddSelectedFiles("name = *.xml  and  size > 1024kb", true);
    zip.Save(PathToZipArchive);
}
CopyVB.NET
Using zip As ZipFile = New ZipFile()
    ' Use a compound expression in the selectionCriteria string.
    zip.AddSelectedFiles("name = *.xml  and  size > 1024kb", true)
    zip.Save(PathToZipArchive)
End Using

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