ZipFile Class

DotNetZip

Ionic Zip Library v1.9.1.6 ZipFile Class
ReferenceIonic.ZipZipFile
The ZipFile type represents a zip archive file.
Declaration Syntax
C# Visual Basic Visual C++
public class ZipFile : IEnumerable<ZipEntry>, 
	IEnumerable, IDisposable
Public Class ZipFile _
	Implements IEnumerable(Of ZipEntry), IEnumerable,  _
	IDisposable
public ref class ZipFile : IEnumerable<ZipEntry^>, 
	IEnumerable, IDisposable
Members
All Members Constructors Methods Properties Fields Events



Icon Member Description
ZipFile(String)
Creates a new ZipFile instance, using the specified filename.

ZipFile(String, Encoding)
Creates a new ZipFile instance, using the specified name for the filename, and the specified Encoding.

ZipFile()()()()
Create a zip file, without specifying a target filename or stream to save to.

ZipFile(Encoding)
Create a zip file, specifying a text Encoding, but without specifying a target filename or stream to save to.

ZipFile(String, TextWriter)
Creates a new ZipFile instance, using the specified name for the filename, and the specified status message writer.

ZipFile(String, TextWriter, Encoding)
Creates a new ZipFile instance, using the specified name for the filename, the specified status message writer, and the specified Encoding.

AddDirectory(String)
Adds the contents of a filesystem directory to a Zip file archive.

AddDirectory(String, String)
Adds the contents of a filesystem directory to a Zip file archive, overriding the path to be used for entries in the archive.

AddDirectoryByName(String)
Creates a directory in the zip archive.

AddDirectoryWillTraverseReparsePoints
Indicates whether NTFS Reparse Points, like junctions, should be traversed during calls to AddDirectory().

AddEntry(String, String)
Adds a named entry into the zip archive, taking content for the entry from a string.

AddEntry(String, String, Encoding)
Adds a named entry into the zip archive, taking content for the entry from a string, and using the specified text encoding.

AddEntry(String, Stream)
Create an entry in the ZipFile using the given Stream as input. The entry will have the given filename.

AddEntry(String, WriteDelegate)
Add a ZipEntry for which content is written directly by the application.

AddEntry(String, OpenDelegate, CloseDelegate)
Add an entry, for which the application will provide a stream, just-in-time.

AddEntry(String, array<Byte>[]()[][])
Add an entry into the zip archive using the given filename and directory path within the archive, and the given content for the file. No file is created in the filesystem.

AddFile(String)
Adds a File to a Zip file archive.

AddFile(String, String)
Adds a File to a Zip file archive, potentially overriding the path to be used within the zip archive.

AddFiles(IEnumerable<(Of <<'(String>)>>))
This method adds a set of files to the ZipFile.

AddFiles(IEnumerable<(Of <<'(String>)>>), String)
Adds a set of files to the ZipFile, using the specified directory path in the archive.

AddFiles(IEnumerable<(Of <<'(String>)>>), Boolean, String)
Adds a set of files to the ZipFile, using the specified directory path in the archive, and preserving the full directory structure in the filenames.

AddItem(String)
Adds an item, either a file or a directory, to a zip file archive.

AddItem(String, String)
Adds an item, either a file or a directory, to a zip file archive, explicitly specifying the directory path to be used in the archive.

AddProgress
An event handler invoked before, during, and after Adding entries to a zip archive.

AddSelectedFiles(String)
Adds to the ZipFile a set of files from the current working directory on disk, that conform to the specified criteria.

AddSelectedFiles(String, Boolean)
Adds to the ZipFile a set of files from the disk that conform to the specified criteria, optionally recursing into subdirectories.

AddSelectedFiles(String, String)
Adds to the ZipFile a set of files from a specified directory in the filesystem, that conform to the specified criteria.

AddSelectedFiles(String, String, Boolean)
Adds to the ZipFile a set of files from the specified directory on disk, that conform to the specified criteria.

AddSelectedFiles(String, String, String)
Adds to the ZipFile a selection of files from the specified directory on disk, that conform to the specified criteria, and using a specified root path for entries added to the zip archive.

AddSelectedFiles(String, String, String, Boolean)
Adds to the ZipFile a selection of files from the specified directory on disk, that conform to the specified criteria, optionally recursing through subdirectories, and using a specified root path for entries added to the zip archive.

AlternateEncoding
A Text Encoding to use when encoding the filenames and comments for all the ZipEntry items, during a ZipFile.Save() operation.

AlternateEncodingUsage
A flag that tells if and when this instance should apply AlternateEncoding to encode the filenames and comments associated to of ZipEntry objects contained within this instance.

BufferSize
Size of the IO buffer used while saving.

BufferSizeDefault
Default size of the buffer used for IO.

CaseSensitiveRetrieval
Indicates whether to perform case-sensitive matching on the filename when retrieving entries in the zipfile via the string-based indexer.

CheckZip(String)
Checks a zip file to see if its directory is consistent.

CheckZip(String, Boolean, TextWriter)
Checks a zip file to see if its directory is consistent, and optionally fixes the directory if necessary.

CheckZipPassword(String, String)
Verify the password on a zip file.

CodecBufferSize
Size of the work buffer to use for the ZLIB codec during compression.

Comment
A comment attached to the zip archive.

CompressionLevel
Sets the compression level to be used for entries subsequently added to the zip archive.

CompressionMethod
The compression method for the zipfile.

ContainsEntry(String)
Returns true if an entry by the given name exists in the ZipFile.

Count
Returns the number of entries in the Zip archive.

DefaultEncoding
The default text encoding used in zip archives. It is numeric 437, also known as IBM437.

Dispose()()()()
Closes the read and write streams associated to the ZipFile, if necessary.

Dispose(Boolean)
Disposes any managed resources, if the flag is set, then marks the instance disposed. This method is typically not called explicitly from application code.

EmitTimesInUnixFormatWhenSaving
Specifies whether the Creation, Access, and Modified times for entries added to the zip file will be emitted in "Unix(tm) format" when the zip archive is saved.

EmitTimesInWindowsFormatWhenSaving
Specifies whether the Creation, Access, and Modified times for entries added to the zip file will be emitted in “Windows format” when the zip archive is saved.

Encryption
The Encryption to use for entries added to the ZipFile.

Entries
Returns the readonly collection of entries in the Zip archive.

EntriesSorted
Returns a readonly collection of entries in the Zip archive, sorted by FileName.

EntryFileNames
The list of filenames for the entries contained within the zip archive.

Equals(Object)
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
ExtractAll(String)
Extracts all of the items in the zip archive, to the specified path in the filesystem. The path can be relative or fully-qualified.

ExtractAll(String, ExtractExistingFileAction)
Extracts all of the items in the zip archive, to the specified path in the filesystem, using the specified behavior when extraction would overwrite an existing file.

ExtractExistingFile
The action the library should take when extracting a file that already exists.

ExtractProgress
An event handler invoked before, during, and after extraction of entries in the zip archive.

ExtractSelectedEntries(String)
Selects and Extracts a set of Entries from the ZipFile.

ExtractSelectedEntries(String, ExtractExistingFileAction)
Selects and Extracts a set of Entries from the ZipFile.

ExtractSelectedEntries(String, String)
Selects and Extracts a set of Entries from the ZipFile.

ExtractSelectedEntries(String, String, String)
Selects and Extracts a set of Entries from the ZipFile.

ExtractSelectedEntries(String, String, String, ExtractExistingFileAction)
Selects and Extracts a set of Entries from the ZipFile.

Finalize()()()()
Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
(Inherited from Object.)
FixZipDirectory(String)
Rewrite the directory within a zipfile.

FlattenFoldersOnExtract
Indicates whether extracted files should keep their paths as stored in the zip archive.

FullScan
Indicates whether to perform a full scan of the zip file when reading it.

GetEnumerator()()()()
Generic IEnumerator support, for use of a ZipFile in an enumeration.

GetHashCode()()()()
Serves as a hash function for a particular type.
(Inherited from Object.)
GetNewEnum()()()()
An IEnumerator, for use of a ZipFile in a foreach construct.

GetType()()()()
Gets the Type of the current instance.
(Inherited from Object.)
Info
Provides a human-readable string with information about the ZipFile.

Initialize(String)
Initialize a ZipFile instance by reading in a zip file.

InputUsesZip64
Indicates whether the most recent Read() operation read a zip file that uses ZIP64 extensions.

IsZipFile(String)
Checks the given file to see if it appears to be a valid zip file.

IsZipFile(String, Boolean)
Checks a file to see if it is a valid zip file.

IsZipFile(Stream, Boolean)
Checks a stream to see if it contains a valid zip archive.

Item[([( Int32])])
This is an integer indexer into the Zip archive.

Item[([( String])])
This is a name-based indexer into the Zip archive.

LibraryVersion
Returns the version number on the DotNetZip assembly.

MaxOutputSegmentSize
The maximum size of an output segment, when saving a split Zip file.

MemberwiseClone()()()()
Creates a shallow copy of the current Object.
(Inherited from Object.)
Name
The name of the ZipFile, on disk.

NumberOfSegmentsForMostRecentSave
Returns the number of segments used in the most recent Save() operation.

OutputUsedZip64
Indicates whether the most recent Save() operation used ZIP64 extensions.

ParallelDeflateMaxBufferPairs
The maximum number of buffer pairs to use when performing parallel compression.

ParallelDeflateThreshold
The size threshold for an entry, above which a parallel deflate is used.

Password
Sets the password to be used on the ZipFile instance.

ProvisionalAlternateEncoding Obsolete.
The text encoding to use when writing new entries to the ZipFile, for those entries that cannot be encoded with the default (IBM437) encoding; or, the text encoding that was used when reading the entries from the ZipFile.

Read(String)
Reads a zip file archive and returns the instance.

Read(String, ReadOptions)
Reads a zip file archive from the named filesystem file using the specified options.

Read(Stream)
Reads a zip archive from a stream.

Read(Stream, ReadOptions)
Reads a zip file archive from the given stream using the specified options.

ReadProgress
An event handler invoked before, during, and after the reading of a zip archive.

RemoveEntries(ICollection<(Of <<'(ZipEntry>)>>))
This method removes a collection of entries from the ZipFile.

RemoveEntries(ICollection<(Of <<'(String>)>>))
This method removes a collection of entries from the ZipFile, by name.

RemoveEntry(ZipEntry)
Removes the given ZipEntry from the zip archive.

RemoveEntry(String)
Removes the ZipEntry with the given filename from the zip archive.

RemoveSelectedEntries(String)
Remove entries from the zipfile by specified criteria.

RemoveSelectedEntries(String, String)
Remove entries from the zipfile by specified criteria, and within the specified path in the archive.

RequiresZip64
Indicates whether the archive requires ZIP64 extensions.

Save()()()()
Saves the Zip archive to a file, specified by the Name property of the ZipFile.

Save(String)
Save the file to a new zipfile, with the given name.

Save(Stream)
Save the zip archive to the specified stream.

SaveProgress
An event handler invoked when a Save() starts, before and after each entry has been written to the archive, when a Save() completes, and during other Save events.

SaveSelfExtractor(String, SelfExtractorFlavor)
Saves the ZipFile instance to a self-extracting zip archive.

SaveSelfExtractor(String, SelfExtractorSaveOptions)
Saves the ZipFile instance to a self-extracting zip archive, using the specified save options.

SelectEntries(String)
Retrieve entries from the zipfile by specified criteria.

SelectEntries(String, String)
Retrieve entries from the zipfile by specified criteria.

SetCompression
A callback that allows the application to specify the compression level to use for entries subsequently added to the zip archive.

SortEntriesBeforeSaving
Whether to sort the ZipEntries before saving the file.

StatusMessageTextWriter
Gets or sets the TextWriter to which status messages are delivered for the instance.

Strategy
The compression strategy to use for all entries.

TempFileFolder
Gets or sets the name for the folder to store the temporary file this library writes when saving a zip archive.

ToString()()()()
Provides a string representation of the instance.
(Overrides Object.ToString()()()().)
UpdateDirectory(String)
Add or update a directory in a zip archive.

UpdateDirectory(String, String)
Add or update a directory in the zip archive at the specified root directory in the archive.

UpdateEntry(String, String)
Updates the given entry in the ZipFile, using the given string as content for the ZipEntry.

UpdateEntry(String, String, Encoding)
Updates the given entry in the ZipFile, using the given string as content for the ZipEntry.

UpdateEntry(String, WriteDelegate)
Updates the given entry in the ZipFile, using the given delegate as the source for content for the ZipEntry.

UpdateEntry(String, OpenDelegate, CloseDelegate)
Updates the given entry in the ZipFile, using the given delegates to open and close the stream that provides the content for the ZipEntry.

UpdateEntry(String, Stream)
Updates the given entry in the ZipFile, using the given stream as input, and the given filename and given directory Path.

UpdateEntry(String, array<Byte>[]()[][])
Updates the given entry in the ZipFile, using the given byte array as content for the entry.

UpdateFile(String)
Adds or Updates a File in a Zip file archive.

UpdateFile(String, String)
Adds or Updates a File in a Zip file archive.

UpdateFiles(IEnumerable<(Of <<'(String>)>>))
Adds or updates a set of files in the ZipFile.

UpdateFiles(IEnumerable<(Of <<'(String>)>>), String)
Adds or updates a set of files to the ZipFile, using the specified directory path in the archive.

UpdateItem(String)
Add or update a file or directory in the zip archive.

UpdateItem(String, String)
Add or update a file or directory.

UpdateSelectedFiles(String, String, String, Boolean)
Updates the ZipFile with a selection of files from the disk that conform to the specified criteria.

UseUnicodeAsNecessary Obsolete.
Indicates whether to encode entry filenames and entry comments using Unicode (UTF-8).

UseZip64WhenSaving
Specify whether to use ZIP64 extensions when saving a zip archive.

ZipError
An event that is raised when an error occurs during open or read of files while saving a zip archive.

ZipErrorAction
The action the library should take when an error is encountered while opening or reading files as they are saved into a zip archive.

Remarks

This is the main type in the DotNetZip class library. This class reads and writes zip files, as defined in the specification for zip files described by PKWare. The compression for this implementation is provided by a managed-code version of Zlib, included with DotNetZip in the classes in the Ionic.Zlib namespace.

This class provides a general purpose zip file capability. Use it to read, create, or update zip files. When you want to create zip files using a Stream type to write the zip file, you may want to consider the ZipOutputStream class.

Both the ZipOutputStream class and the ZipFile class can be used to create zip files. Both of them support many of the common zip features, including Unicode, different compression methods and levels, and ZIP64. They provide very similar performance when creating zip files.

The ZipFile class is generally easier to use than ZipOutputStream and should be considered a higher-level interface. For example, when creating a zip file via calls to the PutNextEntry() and Write() methods on the ZipOutputStream class, the caller is responsible for opening the file, reading the bytes from the file, writing those bytes into the ZipOutputStream, setting the attributes on the ZipEntry, and setting the created, last modified, and last accessed timestamps on the zip entry. All of these things are done automatically by a call to ZipFile.AddFile(). For this reason, the ZipOutputStream is generally recommended for use only when your application emits arbitrary data, not necessarily data from a filesystem file, directly into a zip file, and does so using a Stream metaphor.

Aside from the differences in programming model, there are other differences in capability between the two classes.

  • ZipFile can be used to read and extract zip files, in addition to creating zip files. ZipOutputStream cannot read zip files. If you want to use a stream to read zip files, check out the ZipInputStream class.
  • ZipOutputStream does not support the creation of segmented or spanned zip files.
  • ZipOutputStream cannot produce a self-extracting archive.

Be aware that the ZipFile class implements the IDisposable interface. In order for ZipFile to produce a valid zip file, you use use it within a using clause (Using in VB), or call the Dispose() method explicitly. See the examples for how to employ a using clause.

Inheritance Hierarchy
Object
ZipFile

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