添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
奔放的包子  ·  设备信息 device·  昨天    · 
愤怒的豆芽  ·  RELEASED - [SMAPI] ...·  21 小时前    · 
重感情的板凳  ·  scala ...·  2 小时前    · 
老实的绿茶  ·  ASA Asia·  2 月前    · 
绅士的莲藕  ·  粤剧服饰_IN岭南_金羊网·  8 月前    · 
从容的火锅  ·  三生三世| ...·  10 月前    · 
朝气蓬勃的油条  ·  Seleniumbasic·  11 月前    · 

C# ZipFile CreateFromDirectory(String, String, CompressionLevel, Boolean, Encoding)

Description

ZipFile CreateFromDirectory(String, String, CompressionLevel, Boolean, Encoding) 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.

Syntax

ZipFile.CreateFromDirectory(String, String, CompressionLevel, Boolean, Encoding) has the following syntax.

public static void CreateFromDirectory( string sourceDirectoryName, / / w w w . j a v a 2 s . c o m string destinationArchiveFileName, CompressionLevel compressionLevel, bool includeBaseDirectory, Encoding entryNameEncoding

Parameters

ZipFile.CreateFromDirectory(String, String, CompressionLevel, Boolean, Encoding) has the following parameters.

  • sourceDirectoryName - The path to the directory to be archived, specified as a relative or absolute path. A relative path is interpreted as relative to the current working directory.
  • destinationArchiveFileName - The path of the archive to be created, specified as a relative or absolute path. A relative path is interpreted as relative to the current working directory.
  • compressionLevel - One of the enumeration values that indicates whether to emphasize speed or compression effectiveness when creating the entry.
  • includeBaseDirectory - true to include the directory name from sourceDirectoryName at the root of the archive; false to include only the contents of the directory.
  • entryNameEncoding - 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.
  • Returns

    ZipFile.CreateFromDirectory(String, String, CompressionLevel, Boolean, Encoding) method returns

    Example

    
    // ww w  .  java2 s . c o  m
    using System;
    using System.IO;
    using System.IO.Compression;
    class Program
        static void Main(string[] args)
            string startPath = @"c:\example\start";
            string zipPath = @"c:\example\result.zip";
            string extractPath = @"c:\example\extract";
            ZipFile.CreateFromDirectory(startPath, zipPath, CompressionLevel.Fastest, true,UTF8);