ZipArchive Class

Inheritance Hierarchy

System.Object
  Microsoft.TeamFoundation.Framework.Server.ZipArchive

Namespace:  Microsoft.TeamFoundation.Framework.Server
Assembly:  Microsoft.TeamFoundation.Framework.Server (in Microsoft.TeamFoundation.Framework.Server.dll)

Syntax

'Declaration
Public Class ZipArchive _
    Implements IDisposable
public class ZipArchive : IDisposable
public ref class ZipArchive : IDisposable
type ZipArchive =  
    class 
        interface IDisposable 
    end
public class ZipArchive implements IDisposable

The ZipArchive type exposes the following members.

Constructors

  Name Description
Public method ZipArchive(Stream) Initializes a new instance of ZipArchive on the given stream for reading.
Public method ZipArchive(String) Opens a ZipArchive on the specified path for reading. The specified file is opened by using FileMode.Open.
Public method ZipArchive(Stream, ZipArchiveMode) Initializes a new instance of ZipArchive on the given stream in the specified mode.
Public method ZipArchive(String, ZipArchiveMode) Opens a ZipArchive on the specified path in the specified ZipArchiveMode mode.
Public method ZipArchive(Stream, ZipArchiveMode, Boolean) Initializes a new instance of ZipArchive on the given stream in the specified mode, specifying whether to leave the stream open.

Top

Properties

  Name Description
Public property Entries The collection of entries that are currently in the ZipArchive. This may not accurately represent the actual entries that are present in the underlying file or stream.
Public property Mode The ZipArchiveMode that the ZipArchive was initialized with.

Top

Methods

  Name Description
Public method CreateEntry(String) Creates an empty entry in the Zip archive with the specified entry name. There are no restrictions on the names of entries. The last write time of the entry is set to the current time. If an entry with the specified name already occurs in the archive, a second entry will be created that has the same name.Since no CompressionLevel is specified, the default provided by the implementation of the underlying compression algorithm will be used; the ZipArchive will not impose its own default.Currently, the underlying compression algorithm is provided by the System.IO.Compression.DeflateStreamclass.
Public method CreateEntry(String, CompressionLevel) Creates an empty entry in the Zip archive with the specified entry name. There are no restrictions on the names of entries. The last write time of the entry is set to the current time. If an entry with the specified name already occurs in the archive, a second entry will be created that has the same name.
Public method CreateEntryFromFile(String, String) Adds a file from the file system to the archive under the specified entry name. The new entry in the archive will contain the contents of the file. The last write time of the archive entry is set to the last write time of the file on the file system. If an entry with the specified name already occurs in the archive, a second entry will be created that has the same name. If the specified source file has an invalid last modified time, the first datetime representable in the Zip timestamp format (midnight on January 1, 1980) will be used. If an entry with the specified name already occurs in the archive, a second entry will be created that has the same name.Since no CompressionLevel is specified, the default provided by the implementation of the underlying compression algorithm will be used; the ZipArchive will not impose its own default.Currently, the underlying compression algorithm is provided by the System.IO.Compression.DeflateStreamclass.
Public method CreateEntryFromFile(String, String, CompressionLevel) Adds a file from the file system to the archive under the specified entry name. The new entry in the archive will contain the contents of the file. The last write time of the archive entry is set to the last write time of the file on the file system. If an entry with the specified name already occurs in the archive, a second entry will be created that has the same name. If the specified source file has an invalid last modified time, the first datetime representable in the Zip timestamp format (midnight on January 1, 1980) will be used.
Public methodStatic member CreateFromDirectory(String, String) Creates a Zip archive at the path destinationArchive that contains the files and directories in the directory specified by sourceDirectoryName. The directory structure is preserved in the archive, and a recursive search is performed for files to be archived. The archive must not exist. If the directory is empty, an empty archive will be created. If a file in the directory cannot be added to the archive, the archive will be left incomplete and invalid and the method will throw an exception. This method does not include the base directory in the archive. If an error is encountered when adding files to the archive, this method will stop adding files and leave the archive in an invalid state. The paths are permitted to specify relative or absolute path information. Relative path information is interpreted as relative to the current working directory. If a file in the archive has data in the last write time field that is not a valid Zip timestamp, an indicator value of 1980 January 1 at midnight will be used for the file's last modified time. If an entry with the specified name already occurs in the archive, a second entry will be created that has the same name.Since no CompressionLevel is specified, the default provided by the implementation of the underlying compression algorithm will be used; the ZipArchivewill not impose its own default.Currently, the underlying compression algorithm is provided by the System.IO.Compression.DeflateStreamclass.
Public methodStatic member CreateFromDirectory(String, String, CompressionLevel, Boolean) Creates a Zip archive at the path destinationArchive that contains the files and directories in the directory specified by sourceDirectoryName. The directory structure is preserved in the archive, and a recursive search is performed for files to be archived. The archive must not exist. If the directory is empty, an empty archive will be created. If a file in the directory cannot be added to the archive, the archive will be left incomplete and invalid and the method will throw an exception. This method optionally includes the base directory in the archive. If an error is encountered when adding files to the archive, this method will stop adding files and leave the archive in an invalid state. The paths are permitted to specify relative or absolute path information. Relative path information is interpreted as relative to the current working directory. If a file in the archive has data in the last write time field that is not a valid Zip timestamp, an indicator value of 1980 January 1 at midnight will be used for the file's last modified time.
Public method Dispose() Finishes writing the archive and releases all resources used by the ZipArchive object, unless the object was constructed with leaveOpen as true. Any streams from opened entries in the ZipArchive still open will throw exceptions on subsequent writes, as the underlying streams will have been closed.
Protected method Dispose(Boolean) Releases the unmanaged resources used by ZipArchive and optionally finishes writing the archive and releases the managed resources.
Public method Equals Determines whether the specified object is equal to the current object. (Inherited from Object.)
Public method ExtractToDirectory(String) Extracts all of the files in the archive to a directory on the file system. The specified directory must not exist. This method will create all subdirectories and the specified directory. If there is an error when extracting the archive, the archive will remain partially extracted. Each entry will be extracted so that the extracted file has the same relative path of destinationDirectoryName as the entry has to the root of the archive. If a file to be archived has an invalid last modified time, the first datetime representable in the Zip timestamp format (midnight on January 1, 1980) will be used.
Public methodStatic member ExtractToDirectory(String, String) Extracts all of the files in the specified archive to a directory on the file system. The specified directory must not exist. This method will create all subdirectories and the specified directory. If there is an error when extracting the archive, the archive will remain partially extracted. Each entry will be extracted so that the extracted file has the same relative path of the destinationDirectoryName as the entry has to the archive. The path is permitted to specify relative or absolute path information. Relative path information is interpreted as relative to the current working directory. If a file to be archived has an invalid last modified time, the first datetime representable in the Zip timestamp format (midnight on January 1, 1980) will be used.
Protected method Finalize Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method GetEntry Retrieves a wrapper for the file entry in the archive with the specified name. Names are compared using ordinal comparison. If there are multiple entries in the archive with the specified name, the first found will be returned.
Public method GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Protected method MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public method ToString Returns a string that represents the current object. (Inherited from Object.)

Top

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

Microsoft.TeamFoundation.Framework.Server Namespace