AddSelectedFiles Method (selectionCriteria, directoryOnDisk, recurseDirectories)

DotNetZip

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

This method selects files from the the specified disk directory matching the specified selection criteria, and adds them to the ZipFile. If recurseDirectories is true, files are also selected from subdirectories.

The full directory structure in the filesystem is reproduced on the entries added to 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 *.csv files in the "files" directory, or any subdirectory, that have been saved since 2009 February 14th.
CopyC#
using (ZipFile zip = new ZipFile())
{
    // Use a compound expression in the selectionCriteria string.
    zip.AddSelectedFiles("name = *.csv  and  mtime > 2009-02-14", "files", true);
    zip.Save(PathToZipArchive);
}
CopyVB.NET
Using zip As ZipFile = New ZipFile()
    ' Use a compound expression in the selectionCriteria string.
    zip.AddSelectedFiles("name = *.csv  and  mtime > 2009-02-14", "files", true)
    zip.Save(PathToZipArchive)
End Using
Examples
This example zips up all files in the current working directory, and all its child directories, except those in the excludethis subdirectory.
CopyVB.NET
Using Zip As ZipFile = New ZipFile(zipfile)
  Zip.AddSelectedFfiles("name != 'excludethis\*.*'", datapath, True)
  Zip.Save()
End Using

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