Hi,
I tried to zip 400 files using the below code. But only first some documents are zipping. Can you please tell me what the issue will be?
// Use fast compression
var options = new ArchiveSaveOptions
{
Encoding = System.Text.Encoding.UTF8
};
using (var archive = new Archive())
{
archive.CreateEntries(folderPath);
archive.Save(zipPath);
}
Thanks
Jithin V P
are you getting any exception
Hello @jithin.p,
There are limilations of trial version. So, you can compress up to 10 entries within a ZIP archive in evaluation mode.
If you want to test Aspose.ZIP without evaluation version limitations, you can request a 30 Day Temporary License.
No there is no exception so far.
Hi,
I already have a licensed version of Aspose. I am using aspose.words, aspose.pdf, etc. dll from aspose. Does aspose.zip need any separate license other than the existing one? Please guide me?
Thanks
Jithin V P
It seems you have Aspose.Total license. It fits for Aspose.Zip too. You need to set it like that:
Aspose.Zip.License license = new Aspose.Zip.License();
license.SetLicense("Aspose.Total.NET.lic");
Hi,
How can I speed up the zipping of 400 files using ASPOSE.ZIP dll?
Thanks
Jithin V P
Hello @jithin.p,
Compression time mostly depends on the data you are compressing—its size and redundancy. However, there are steps you can take to speed it up.
First - Utilize multiple cores of your CPU.
Familiarize yourself with the approach Aspose.Zip uses for multi-threaded zip composition by reading this article. You can configure multithreading by setting ParallelOptions when saving the archive.
If your files are small and there is no risk of memory exhaustion, set parallel mode to ParallelCompressionMode.Always. Full code example:
using (var archive = new Archive())
{
archive.CreateEntries(folderPath);
archive.Save(zipPath, new ArchiveSaveOptions() {
ParallelOptions = new ParallelOptions() { ParallelCompressInMemory = ParallelCompressionMode.Always }}
);
}
If your files are large and there is a risk of memory exhaustion, set can set parallel mode to ParallelCompressionMode.Auto. Full code example:
using (var archive = new Archive())
{
archive.CreateEntries(folderPath);
archive.Save(zipPath, new ArchiveSaveOptions() {
ParallelOptions = new ParallelOptions {
ParallelCompressInMemory = ParallelCompressionMode.Auto,
AvailableMemorySize = 4000 }}
);
}
Adjust AvailableMemorySize based on your conditions, considering RAM size, processes running, OS swap and so on.
Second – experiment with different compression algorithms.
Aspose.Zip supports Deflate, Deflate64™ (a trademark of PKWARE Inc.), Bzip2, PPMd, LZMA, Xz, Zstandard compression on ZIP archive composition. It also supports Store method, which means no compression. Deflate is the default and most popular option, but another algorithm might perform faster in your case.
So, try out the available algorithms.
Set the compression setting as follows
CompressionSetting cs = new DeflateCompressionSettings() for Deflate,
CompressionSetting cs = new EnhancedDeflateCompressionSettings() for Deflate64™,
CompressionSetting cs = new Bzip2CompressionSettings() for Bzip2,
CompressionSetting cs = new PPMdCompressionSettings() for PPMd,
CompressionSetting cs = new LzmaCompressionSettings() for LZMA,
CompressionSetting cs = new XzCompressionSettings() for Xz,
CompressionSetting cs = new ZstandardCompressionSettings() for Zstandard.
Then apply the chosen setting during archive composition:
using (var archive = new Archive(new ArchiveEntrySettings(cs)))
{
archive.CreateEntries(folderPath);
archive.Save(zipPath);
}
I recommend measuring the effect of changing algorithms using the BenchmarkDotNet library.
While benchmarking, avoid enabling parallel compression from the previous step to properly assess the impact of the algorithm alone.
Also note that some algorithms have adjustable settings themselves.
Once you identify the most suitable algorithm for your data, you can apply the multi-threaded approach. Keep in mind that in ParallelCompressionMode.Auto, entries using PPMd and LZMA algorithms are compressed sequentially (on a single thread).
Thanks, I will check. How can I set the author title in the metadata of a PDF while converting from Word to PDF?
Please help me?
Please consult in PDF or Words forum.