Get Started - Create a ZIP Archive
- 2 minutes to read
Important
You need a license for the DevExpress Office File API Subscription or DevExpress Universal Subscription to use these examples in production code.
This article describes how to get started with the ZIP compression component for .NET Framework and .NET Core.
Create a .NET Framework Application
Create a new Console Application (.NET Framework) project.
Add a reference to the DevExpress.Docs.v24.1.dll library.
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 24.1\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); } }
Run the project. The code example creates the Test.zip archive with all files encrypted using “123” password.
Create a .NET Core Application
Start Microsoft Visual Studio and create a new Console Application (.NET Core) project.
Install the DevExpress.Document.Processor NuGet package.
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 24.1\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); } }
Run the project. The code example creates the Test.zip archive with all files encrypted using “123” password.