ZipArchive.AddFiles(IEnumerable<String>) Method
Adds files to archive.
Namespace: DevExpress.Compression
Assembly: DevExpress.Docs.v24.1.dll
NuGet Package: DevExpress.Document.Processor
Declaration
Parameters
Name | Type | Description |
---|---|---|
fileNames | IEnumerable<String> | A list of file names which implements the IEnumerable<T><String,> interface. |
Remarks
The AddFiles method enables you to batch add files to the archive. The archive path to which the files will be added is constructed from the file path by discarding the root path component, i.e., the file path “C:\Temp\test.txt” will be the “Temp/test.txt”.
This example recursively enumerates all files that have a .txt extension, reads each line of the file, and if a line contains the string “DevExpress”, the file is added to archive.
using DevExpress.Compression;
public void ArchiveFilesBatch() {
string path = this.startupPath;
using (ZipArchive archive = new ZipArchive()) {
var files = from file in System.IO.Directory.EnumerateFiles(path, "*.xml",
System.IO.SearchOption.AllDirectories)
from line in System.IO.File.ReadLines(file)
where line.Contains("DevExpress")
select file;
archive.AddFiles(files);
archive.Save("Documents\\ArchiveFilesBatch.zip");
}
}
Related GitHub Examples
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the AddFiles(IEnumerable<String>) method.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.