ZipFile Constructor (fileName, statusMessageWriter)

DotNetZip

Ionic Zip Library v1.9.1.6 ZipFile Constructor (fileName, statusMessageWriter)
ReferenceIonic.ZipZipFileZipFile(String, TextWriter)
Creates a new ZipFile instance, using the specified name for the filename, and the specified status message writer.
Declaration Syntax
C# Visual Basic Visual C++
public ZipFile(
	string fileName,
	TextWriter statusMessageWriter
)
Public Sub New ( _
	fileName As String, _
	statusMessageWriter As TextWriter _
)
public:
ZipFile(
	String^ fileName, 
	TextWriter^ statusMessageWriter
)
Parameters
fileName (String)
The filename to use for the new zip archive.
statusMessageWriter (TextWriter)
A TextWriter to use for writing verbose status messages.
Remarks

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

This version of the constructor allows the caller to pass in a TextWriter, to which verbose messages will be written during extraction or creation of the zip archive. A console application may wish to pass System.Console.Out to get messages on the Console. A graphical or headless application may wish to capture the messages in a different TextWriter, for example, a StringWriter, and then display the messages in a TextBox, or generate an audit log of ZipFile operations.

To encrypt the data for the files added to the ZipFile instance, set the Password property after creating the ZipFile instance.

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

Examples
CopyC#
using (ZipFile zip = new ZipFile("Backup.zip", Console.Out))
{
  // Store all files found in the top level directory, into the zip archive.
  // note: this code does not recurse subdirectories!
  // Status messages will be written to Console.Out
  String[] filenames = System.IO.Directory.GetFiles(DirectoryToZip);
  zip.AddFiles(filenames);
  zip.Save();
}
CopyVB.NET
Using zip As New ZipFile("Backup.zip", Console.Out)
    ' Store all files found in the top level directory, into the zip archive.
    ' note: this code does not recurse subdirectories!
    ' Status messages will be written to Console.Out
    Dim filenames As String() = System.IO.Directory.GetFiles(DirectoryToZip)
    zip.AddFiles(filenames)
    zip.Save()
End Using
Exceptions
Exception Condition
ZipException Thrown if name refers to an existing file that is not a valid zip file.

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