Delen via


ZipArchive.CreateFromDirectory Method

Include Protected Members
Include Inherited Members

This member is overloaded. For complete information about this member, including syntax, usage, and examples, click a name in the overload list.

Overload List

  Name Description
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 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.)
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 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.

Top

See Also

Reference

ZipArchive Class

Microsoft.TeamFoundation.Server.Core Namespace