ZipArchive Class
Inheritance Hierarchy
System.Object
Microsoft.TeamFoundation.Server.Core.ZipArchive
Namespace: Microsoft.TeamFoundation.Server.Core
Assembly: Microsoft.TeamFoundation.Server.Core (in Microsoft.TeamFoundation.Server.Core.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 | |
---|---|---|
ZipArchive(Stream) | Initializes a new instance of ZipArchive on the given stream for reading. | |
ZipArchive(String) | Opens a ZipArchive on the specified path for reading. The specified file is opened with FileMode.Open. | |
ZipArchive(Stream, ZipArchiveMode) | Initializes a new instance of ZipArchive on the given stream in the specified mode. | |
ZipArchive(String, ZipArchiveMode) | Opens a ZipArchive on the specified path in the specified ZipArchiveMode mode. | |
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 | |
---|---|---|
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. | |
Mode | The ZipArchiveMode that the ZipArchive was initialized with. |
Top
Methods
Name | Description | |
---|---|---|
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 exists in the archive, a second entry will be created that has an identical 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.DeflateStream class.) | |
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 exists in the archive, a second entry will be created that has an identical name. | |
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 exists in the archive, a second entry will be created that has an identical 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 exists in the archive, a second entry will be created that has an identical 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.DeflateStream class.) |
|
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 exists in the archive, a second entry will be created that has an identical 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. | |
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 done 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 while 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 exists in the archive, a second entry will be created that has an identical 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.DeflateStream class.) |
|
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 done 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 while 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. | |
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. | |
Dispose(Boolean) | Releases the unmanaged resources used by ZipArchive and optionally finishes writing the archive and releases the managed resources. | |
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) | |
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 while extracting the archive, the archive will remain partially extracted. Each entry will be extracted such that the extracted file has the same relative path to 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. | |
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 while extracting the archive, the archive will remain partially extracted. Each entry will be extracted such that the extracted file has the same relative path to 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. | |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | |
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 one found will be returned. | |
GetHashCode | Serves as the default hash function. (Inherited from Object.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
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.