Last active
March 14, 2025 14:07
Create ZIP in C#. For details: https://kb.aspose.com/zip/net/create-zip-in-csharp/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Text; | |
using Aspose.Zip; | |
using Aspose.Zip.Saving; | |
License lic = new License(); | |
lic.SetLicense("license.lic"); | |
// Create FileStream for output ZIP archive | |
using (FileStream zipFile = File.Open("csv_archive.zip", FileMode.Create)) | |
{ | |
// File to be added to archive | |
using (FileStream source1 = File.Open("ClientData.xml", FileMode.Open, FileAccess.Read)) | |
{ | |
// File to be added to archive | |
using (FileStream source2 = File.Open("TextBox_out.pdf", FileMode.Open, FileAccess.Read)) | |
{ | |
using (var archive = new Archive()) | |
{ | |
// Add files to the archive | |
archive.CreateEntry("ClientData.xml", source1); | |
archive.CreateEntry("TextBox_out.pdf", source2); | |
// ZIP the files | |
archive.Save(zipFile, new ArchiveSaveOptions() | |
{ | |
Encoding = Encoding.ASCII, | |
ArchiveComment = | |
"Compressed Files" | |
}); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment