AddFiles Method (fileNames)

DotNetZip

Ionic Zip Library v1.9.1.6 AddFiles Method (fileNames)
ReferenceIonic.ZipZipFileAddFiles(IEnumerable<(Of <<'(String>)>>))
This method adds a set of files to the ZipFile.
Declaration Syntax
C# Visual Basic Visual C++
public void AddFiles(
	IEnumerable<string> fileNames
)
Public Sub AddFiles ( _
	fileNames As IEnumerable(Of String) _
)
public:
void AddFiles(
	IEnumerable<String^>^ fileNames
)
Parameters
fileNames (IEnumerable<(Of <(<'String>)>)>)
The collection of names of the files to add. Each string should refer to a file in the filesystem. The name of the file may be a relative path or a fully-qualified path.
Remarks

Use this method to add a set of files to the zip archive, in one call. For example, a list of files received from System.IO.Directory.GetFiles() can be added to a zip archive in one call.

For ZipFile properties including Encryption, Password, SetCompression, ProvisionalAlternateEncoding, ExtractExistingFile, ZipErrorAction, and CompressionLevel, their respective values at the time of this call will be applied to each ZipEntry added.

Examples
This example shows how to create a zip file, and add a few files into it.
CopyC#
String ZipFileToCreate = "archive1.zip";
String DirectoryToZip = "c:\\reports";
using (ZipFile zip = new ZipFile())
{
  // Store all files found in the top level directory, into the zip archive.
  String[] filenames = System.IO.Directory.GetFiles(DirectoryToZip);
  zip.AddFiles(filenames);
  zip.Save(ZipFileToCreate);
}
CopyVB.NET
Dim ZipFileToCreate As String = "archive1.zip"
Dim DirectoryToZip As String = "c:\reports"
Using zip As ZipFile = New ZipFile
    ' Store all files found in the top level directory, into the zip archive.
    Dim filenames As String() = System.IO.Directory.GetFiles(DirectoryToZip)
    zip.AddFiles(filenames)
    zip.Save(ZipFileToCreate)
End Using

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