Home Forums .NET libraries Xceed Zip & Real-Time Zip for .NET Adjust the compression ratio for a file

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #19851 |

    Please forgive me if this is in the incorrect forum.

    I am currently trying to use the QuickZip.Zip method to compress files before they are sent out via email. My SMTP sever does not allow “Extreme Compressed” files to be sent or received. Is there a way to adjust the compression ratio to a lower level?

    The function call that I am using is:

    QuickZip.Zip(sZipPath, true, true, false, sFilePath);

    Imported from legacy forums. Posted by Richard (had 3463 views)

    User (Old forums)
    Member
    Post count: 23064

    I forgot to mention that I am using C#.

    Thank you for your help.

    Imported from legacy forums. Posted by Richard (had 205 views)

    Xceed Support
    Member
    Post count: 5658

    When you are using the QuickZip methods, you can adjust the Compression Methods, but not the Compression Levels. However, if you use our FileSystem, you can change the Compression Levels.

    Here is a snippet of code that shows how to do the same procedure.

    e.g.,
    <code>
    string sZipPath = “path to the zip archive”;
    string sFilePath = “path to file to zip”;

    AbstractFile zipFile = new DiskFile( sZipPath );
    ZipArchive archive = new ZipArchive( zipFile );

    archive.DefaultCompressionLevel = CompressionLevel.Lowest;

    archive.BeginUpdate();

    AbstractFile file = new DiskFile( sFilePath );
    file.CopyTo( archive, true );

    archive.EndUpdate();
    </code>

    Imported from legacy forums. Posted by CharlesB (had 224 views)

    User (Old forums)
    Member
    Post count: 23064

    Thank you for your help. While going through your documentatino, I found the another solution as well. I used ZipArchive to create the zip file. I will give your suggestion a try as well.

    string zipFilename = @”C:\TestZip\SourceFile.zip”;
    string sourceFolder = @”C:\TestZip\”;
    string fileMask = “*.pdf”;
    bool recursive = true;

    DiskFile zipFile = new DiskFile(zipFilename);

    zipFile.Create();

    ZipArchive zip = new ZipArchive(zipFile);

    zip.DefaultCompressionLevel = CompressionLevel.Lowest;

    DiskFolder zipSource = new DiskFolder(sourceFolder);

    ZipEvents zipEvents = new ZipEvents();

    zipEvents.ItemProgression += new ItemProgressionEventHandler( OnItemProgression );

    zipEvents.DiskRequired += new DiskRequiredEventHandler( OnDiskRequired );

    zipSource.CopyFilesTo(zipEvents, “Zipping”, zip, recursive, true, fileMask);

    Imported from legacy forums. Posted by Richard (had 4110 views)

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.