C# | Visual Basic | Visual C++ |
public ZipFile( string fileName, TextWriter statusMessageWriter, Encoding encoding )
Public Sub New ( _ fileName As String, _ statusMessageWriter As TextWriter, _ encoding As Encoding _ )
public: ZipFile( String^ fileName, TextWriter^ statusMessageWriter, Encoding^ encoding )
- fileName (String)
- The filename to use for the new zip archive.
- statusMessageWriter (TextWriter)
- A TextWriter to use for writing verbose status messages.
- encoding (Encoding)
- The Encoding is used as the default alternate encoding for entries with filenames or comments that cannot be encoded with the IBM437 code page.
This constructor works like the ZipFile constructor that accepts a single string argument. See that reference for detail on what this constructor does.
This version of the constructor allows the caller to pass in a TextWriter, and an Encoding. The TextWriter will collect verbose messages that are generated by the library 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.
The Encoding is used as the default alternate encoding for entries with filenames or comments that cannot be encoded with the IBM437 code page. This is a equivalent to setting the ProvisionalAlternateEncoding property on the ZipFile instance after construction.
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.
Exception | Condition |
---|---|
ZipException |
Thrown if fileName refers to an existing file that is not a valid zip file.
|