ZipArchive Class

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

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

public class ZipArchive : IDisposable

The ZipArchive type exposes the following members.

  NameDescription
Public methodZipArchive(Stream)Initializes a new instance of ZipArchive on the given stream for reading.
Public methodZipArchive(String)Opens a ZipArchive on the specified path for reading. The specified file is opened by using FileMode.Open.
Public methodZipArchive(Stream, ZipArchiveMode)Initializes a new instance of ZipArchive on the given stream in the specified mode.
Public methodZipArchive(String, ZipArchiveMode)Opens a ZipArchive on the specified path in the specified ZipArchiveMode mode.
Public methodZipArchive(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

  NameDescription
Public propertyEntriesThe 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 propertyModeThe ZipArchiveMode that the ZipArchive was initialized with.
Top

  NameDescription
Public methodCreateEntry(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 methodCreateEntry(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 methodCreateEntryFromFile(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 methodCreateEntryFromFile(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 memberCreateFromDirectory(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 memberCreateFromDirectory(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 methodDispose()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 methodDispose(Boolean)Releases the unmanaged resources used by ZipArchive and optionally finishes writing the archive and releases the managed resources.
Public methodEqualsDetermines whether the specified object is equal to the current object. (Inherited from Object.)
Public methodExtractToDirectory(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 memberExtractToDirectory(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 methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetEntryRetrieves 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 methodGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft