Select Set of Files from One or More Folders & Add to ZIP Archive | C# .NET

Hi,

We have following requirements:

  1. Select certain set of files (based on business logic) from one or more folders

  2. The files selected can be from different folders in same level or can be sub folders of a folder.

  3. The output zip file should maintain the folder structure

Please let us know Aspose Zip for .NET component will support the above requirements.

@testaspo

Yes, you can achieve your requirement using Aspose.ZIP. We suggest you please read the following article.
Compressing and Decompressing Files

You can maintain the folder structure as shown below.

using (var archive = new Archive())
{
    archive.CreateEntry("temp\\users\\alice29.txt", source1);
    archive.CreateEntry("out\\asyoulik.txt", source2);
    archive.Save(zipFile, new ArchiveSaveOptions() { Encoding = Encoding.ASCII, ArchiveComment = "There are two poems from Canterbury corpus" });
}