ZipFile Constructor

DotNetZip

Ionic Zip Library v1.9.1.6 ZipFile Constructor
ReferenceIonic.ZipZipFileZipFile()()()()
Create a zip file, without specifying a target filename or stream to save to.
Declaration Syntax
C# Visual Basic Visual C++
public ZipFile()
Public Sub New
public:
ZipFile()
Remarks

See the documentation on the ZipFile constructor that accepts a single string argument for basic information on all the ZipFile constructors.

After instantiating with this constructor and adding entries to the archive, the application should call Save(String) or Save(Stream) to save to a file or a stream, respectively. The application can also set the Name property and then call the no-argument Save()()()() method. (This is the preferred approach for applications that use the library through COM interop.) If you call the no-argument Save()()()() method without having set the Name of the ZipFile, either through the parameterized constructor or through the explicit property , the Save() will throw, because there is no place to save the file.

Instances of the ZipFile class are not multi-thread safe. You may have multiple threads that each use a distinct ZipFile instance, or you can synchronize multi-thread access to a single instance.

Examples
This example creates a Zip archive called Backup.zip, containing all the files in the directory DirectoryToZip. Files within subdirectories are not zipped up.
CopyC#
using (ZipFile zip = new ZipFile())
{
  // Store all files found in the top level directory, into the zip archive.
  // note: this code does not recurse subdirectories!
  String[] filenames = System.IO.Directory.GetFiles(DirectoryToZip);
  zip.AddFiles(filenames, "files");
  zip.Save("Backup.zip");
}
CopyVB.NET
Using zip As New ZipFile
    ' Store all files found in the top level directory, into the zip archive.
    ' note: this code does not recurse subdirectories!
    Dim filenames As String() = System.IO.Directory.GetFiles(DirectoryToZip)
    zip.AddFiles(filenames, "files")
    zip.Save("Backup.zip")
End Using

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