Zip files c#


















To use the ZipFile class, you must reference the System. FileSystem assembly in your project. The directory structure from the file system is preserved in the archive. If the directory is empty, an empty archive is created. This method overload does not include the base directory in the archive and does not allow you to specify a compression level.

If you want to include the base directory or specify a compression level, call the CreateFromDirectory String, String, CompressionLevel, Boolean method overload. If the archive already exists, an IOException exception is thrown. If an entry with the specified name already exists in the archive, a second entry is created with an identical name.

If a file in the directory cannot be added to the archive, the archive is left incomplete and invalid, and the method throws an IOException exception. One of the enumeration values that indicates whether to emphasize speed or compression effectiveness when creating the entry. When compressing the archive, the base directory is included and the compression level is set to emphasize the speed of the operation over efficiency.

Use this method overload to specify the compression level and whether to include the base directory in the archive. 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. Use this method overload to specify the compression level and character encoding, and whether to include the base directory in the archive.

When you write to archive files and entryNameEncoding is set to a value other than null , the specified entryNameEncoding 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.

Skip to main content. This browser is no longer supported. Download Microsoft Edge More info. Contents Exit focus mode. Zip File. Open Method Reference Is this page helpful? Please rate your experience Yes No. Any additional feedback?

Namespace: System. Compression Assembly: System. Opens a zip archive at the specified path and in the specified mode. Open String, ZipArchiveMode. Applies to. In this article. This example shows how to create and extract a zip archive by using the ZipFile class.

It compresses the contents of a folder into a zip archive, and then extracts that content to a new folder. Creates a zip archive that contains the files and directories from the specified directory, uses the specified compression level, and optionally includes the base directory. Creates a zip archive that contains the files and directories from the specified directory, uses the specified compression level and character encoding for entry names, and optionally includes the base directory.

Extracts all the files in the specified zip archive to a directory on the file system and uses the specified character encoding for entry names.

Opens a zip archive at the specified path, in the specified mode, and by using the specified character encoding for entry names. Skip to main content. This browser is no longer supported. Download Microsoft Edge More info. Contents Exit focus mode. Zip File Class Reference Is this page helpful?



0コメント

  • 1000 / 1000