System.IO.Compression 4.0.0.0 System.Object System.IDisposable

The class enables you to work with a package of compressed files. The package contains an entry for each compressed file. You can:

Retrieve an entry by using the method.

Retrieve the entire collection of entries by using the property.

Create a new entry in the package by calling the overloaded method.

For static methods to create a zip archive from a directory or extract a zip archive to a directory, see the class.

When you create a new entry, the file is compressed and added to the zip package. The method enables you to specify a directory hierarchy when adding the entry. You include the relative path of the new entry within the zip package. For example, creating a new entry with a relative path of AddedFolder\NewFile.txt creates a compressed text file in a directory named AddedFolder.

If you reference the System.IO.Compression.FileSystem assembly in your project, you can access three extension methods (from the class) for the class: , , and . These extension methods enable you to compress and decompress the contents of the entry to a file. The System.IO.Compression.FileSystem assembly is not available for win8_appname_long apps. In win8_appname_long apps, you can compress and decompress files by using the or class, or you can use the wrt types Compressor and Decompressor.

Represents a package of compressed files in the zip archive format.

- Constructor
  4.0.0.0
  To be added.

  Initializes a new instance of the class from the specified stream.

  The stream that contains the archive to be read.
- Constructor
  4.0.0.0

  If the parameter is set to , the stream must support reading. If the parameter is set to , the stream must support writing. If the parameter is set to , the stream must support reading, writing, and seeking.

  Initializes a new instance of the class from the specified stream and with the specified mode.

  The input or output stream.
  One of the enumeration values that indicates whether the zip archive is used to read, create, or update entries.
- Constructor
  4.0.0.0

  If the parameter is set to , the stream must support reading. If the parameter is set to , the stream must support writing. If the parameter is set to , the stream must support reading, writing, and seeking.

  Initializes a new instance of the class on the specified stream for the specified mode, and optionally leaves the stream open.

  The input or output stream.
  One of the enumeration values that indicates whether the zip archive is used to read, create, or update entries.
  true to leave the stream open after the object is disposed; otherwise, false.
- Constructor
  4.0.0.0

  If the parameter is set to , the stream must support reading. If the parameter is set to , the stream must support writing. If the parameter is set to , the stream must support reading, writing, and seeking.

  When you open a zip archive file for reading and is set to null, entry names are decoded according to the following rules:

  When the language encoding flag (in the general-purpose bit flag of the local file header) is not set, the current system default code page is used to decode the entry name.

  When the language encoding flag is set, UTF-8 is used to decode the entry name.

  When you open a zip archive file for reading and is set to a value other than null, entry names are decoded according to the following rules:

  When the language encoding flag is not set, the specified is used to decode the entry name.

  When the language encoding flag is set, UTF-8 is used to decode the entry name.

  When you write to archive files and is set to null, entry names are encoded according to the following rules:

  For entry names that contain characters outside the ASCII range, the language encoding flag is set, and entry names are encoded by using UTF-8.

  For entry names that contain only ASCII characters, the language encoding flag is not set, and entry names are encoded by using the current system default code page.

  When you write to archive files and is set to a value other than null, the specified is used to encode the entry names into bytes. The language encoding flag (in the general-purpose bit flag of the local file header) is set only when the specified encoding is a UTF-8 encoding.

  Initializes a new instance of the class on the specified stream for the specified mode, uses the specified encoding for entry names, and optionally leaves the stream open.

  The input or output stream.
  One of the enumeration values that indicates whether the zip archive is used to read, create, or update entries.
  true to leave the stream open after the object is disposed; otherwise, false.
  The encoding to use when reading or writing entry names in this archive. Specify a value for this parameter only when an encoding is required for interoperability with zip archive tools and libraries that do not support UTF-8 encoding for entry names.
- Method
  4.0.0.0
  System.IO.Compression.ZipArchiveEntry ``

  The string should reflect the relative path of the entry you want to create within the zip archive. There is no restriction on the string you provide. However, if it is not formatted as a relative path, the entry is created, but you may get an exception when you extract the contents of the zip archive. If an entry with the specified path and name already exists in the archive, a second entry is created with the same path and name.

  The value of the property for the new entry is set to the current time. The entry is compressed using the default compression level of the underlying compression algorithm. If you want to specify a different compression level, use the method.

  Creates an empty entry that has the specified path and entry name in the zip archive.

  An empty entry in the zip archive.

  A path, relative to the root of the archive, that specifies the name of the entry to be created.
- Method
  4.0.0.0
  System.IO.Compression.ZipArchiveEntry `` ``

  The string should reflect the relative path of the entry you want to create within the zip archive. There is no restriction on the string you provide. However, if it is not formatted as a relative path, the entry is created, but you may get an exception when you extract the contents of the zip archive. If an entry with the specified name already exists in the archive, a second entry is created with the same name.

  The value of the property for the new entry is set to the current time. Set the parameter to if you want the file to be compressed as much as possible. Set the parameter to only if you are concerned that the compression operation will not complete quickly enough for your scenario.

  Creates an empty entry that has the specified entry name and compression level in the zip archive.

  An empty entry in the zip archive.

  A path, relative to the root of the archive, that specifies the name of the entry to be created. One of the enumeration values that indicates whether to emphasize speed or compression effectiveness when creating the entry.
- Method
  4.0.0.0
  System.Void

  This method finishes writing the archive and releases all resources used by the object. Unless you construct the object by using the constructor overload and set its parameter to true, all underlying streams are closed and no longer available for subsequent write operations.

  When you are finished using this instance of , call to release all resources used by this instance. You should eliminate further references to this instance so that the garbage collector can reclaim the memory of the instance instead of keeping it alive for finalization.

  calls the method, which contains the code to release managed and unmanaged resources. For more information, see Implementing a Dispose Method.

  Releases the resources used by the current instance of the class.

- Method
  4.0.0.0
  System.Void ``

  If is set to true, all underlying streams are closed and no longer available for subsequent write operations, unless you construct the object by using the constructor overload and set its parameter to true.

  This method is called only by the public and methods; do not call this method directly.

  When you implement the dispose pattern, the Boolean parameter of the method should be used as follows:

  The method of the current object should call with the Boolean parameter set to true to release both managed and unmanaged resources.

  The method of the current object should call with the Boolean parameter set to false to release only unmanaged resources.

  For more information, see Implementing a Dispose Method.

  Called by the and methods to release the unmanaged resources used by the current instance of the class, and optionally finishes writing the archive and releases the managed resources.

  true to finish writing the archive and release unmanaged and managed resources; false to release only unmanaged resources.
- Property
  4.0.0.0
  System.Collections.ObjectModel.ReadOnlyCollection<System.IO.Compression.ZipArchiveEntry> To be added.

  Use the property to retrieve the entire collection of entries. Use the method to retrieve a single entry by name.

  Gets the collection of entries that are currently in the zip archive.

- Method
  4.0.0.0
  System.IO.Compression.ZipArchiveEntry ``

  If multiple entries that have the specified name exist in the archive, the first one is returned. The name of the entry is compared to using ordinal comparison.

  Retrieves a wrapper for the specified entry in the zip archive.

  A wrapper for the specified entry in the archive; null if the entry does not exist in the archive.

  A path, relative to the root of the archive, that identifies the entry to retrieve.
- Property
  4.0.0.0
  System.IO.Compression.ZipArchiveMode To be added.

  You specify a value for the property when you create an instance of the class. Use the or constructor to provide a value for the property.

  Gets a value that describes the type of action the zip archive can perform on entries.