Skip to main content
A newer version of this page is available. .
.NET Framework 4.5.2+
  • The page you are viewing does not exist in the .NET Standard 2.0+ platform documentation. This link will take you to the parent topic of the current section.

Get Started - Create a ZIP Archive

  • 2 minutes to read

Important

You need a license to the DevExpress Office File API or DevExpress Universal Subscription to use these examples in production code. Refer to the DevExpress Subscription page for pricing information.

Perform the steps below to get started with the Zip Compression and Archive API.

  1. Create a new Console Application (.NET Framework) project.

  2. Add a reference to the DevExpress.Docs.v19.2.dll library.

  3. Paste the code below in the Main method of the Program.cs file (Main procedure of the Module1.vb file for Visual Basic).

    using DevExpress.Compression;
    // ...
    
    static void Main(string[] args)
    {
        string zipFileName = "d:\\Test.zip";
        string sourceDir = @"C:\Users\Public\Documents\DevExpress Demos 19.2\Components\Data";
        string password = "123";
        EncryptionType encryptionType = EncryptionType.PkZip;
        using (ZipArchive archive = new ZipArchive())
        {
            archive.Password = password;
            archive.EncryptionType = encryptionType;
            archive.AddDirectory(sourceDir);
            archive.Save(zipFileName);
        }
    }
    
  4. Run the project. The code example creates the Test.zip archive with all files encrypted using “123” password.

  1. Start Microsoft Visual Studio and create a new Console Application (.NET Core) project.

  2. Install the DevExpress.WindowsDesktop.Document.Processor NuGet package.

  3. Right-click the project in the Solution Explorer and select Edit Project File.

    Office_NetCore_3_Edit_Project_File

    Change the project’s SDK attribute to Microsoft.NET.Sdk.WindowsDesktop and set the UseWindowsForms option to true.

    <Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
    
      <PropertyGroup>
        <OutputType>Exe</OutputType>
        <TargetFramework>netcoreapp3.0</TargetFramework>
        <UseWindowsForms>true</UseWindowsForms>
      </PropertyGroup>
    </Project>
    
  4. Paste the code below in the Main method of the Program.cs file (Main procedure of the Module1.vb file for Visual Basic).

    using DevExpress.Compression;
    // ...
    
    static void Main(string[] args)
    {
        string zipFileName = "d:\\Test.zip";
        string sourceDir = @"C:\Users\Public\Documents\DevExpress Demos 19.2\Components\Data";
        string password = "123";
        EncryptionType encryptionType = EncryptionType.PkZip;
        using (ZipArchive archive = new ZipArchive())
        {
            archive.Password = password;
            archive.EncryptionType = encryptionType;
            archive.AddDirectory(sourceDir);
            archive.Save(zipFileName);
        }
    }
    
  5. Run the project. The code example creates the Test.zip archive with all files encrypted using “123” password.

See Also