Home Forums .NET libraries Xceed Zip & Real-Time Zip for .NET some xml files taking much much longer to zip than others

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

    Hi,

    I have noticed that different XML files take very different amounts of time to zip, even if the files are of approximately the same size. Sometimes it takes about 7 seconds to zip a 5 megabyte xml file, other times it takes less than a second.  It appears to depend on the schema of the file.  Here is the code we use to zip, does anything jump out as something that could be improved or changed?  The last line, CopyFilesTo(…), is where all the time is taken.

    public void CompressFile(string fullPathZipFileName, string fullPathSourceFile)
    {
     string sourceFolder = Path.GetDirectoryName(fullPathSourceFile);
     string destFolder = Path.GetDirectoryName(fullPathZipFileName);

     if (!Directory.Exists(destFolder))
      Directory.CreateDirectory(destFolder);
     DiskFile zipFile = new DiskFile(fullPathZipFileName);

     if (!zipFile.Exists)
      zipFile.Create();

     ZipArchive zip = new ZipArchive(zipFile);
     zip.DefaultCompressionMethod = CompressionMethod.Deflated;
     zip.DefaultEncryptionPassword = c_EncryptPWD;
     zip.DefaultEncryptionMethod = EncryptionMethod.Compatible;
     zip.DefaultCompressionLevel = CompressionLevel.Highest;
     zip.AllowSpanning = true;

     DiskFolder source = new DiskFolder(sourceFolder);
     
     ZipEvents events = new ZipEvents();
     events.ItemProgression += new ItemProgressionEventHandler(OnItemProgression);
     events.DiskRequired += new DiskRequiredEventHandler(OnDiskRequired);

     source.CopyFilesTo(events, “Zipping”, zip, false, true, Path.GetFileName(fullPathSourceFile));
    }

    Imported from legacy forums. Posted by Mickie (had 1241 views)

    Xceed Support
    Member
    Post count: 5658

    Hi Mickey,

    Try this:

     zip.DefaultCompressionLevel = CompressionLevel.Lowest

    or

     zip.DefaultCompressionLevel = CompressionLevel.Normal

    Instead of the one you are using to see if any changes will occur.

    Regards,

     Alain

    Imported from legacy forums. Posted by Alain [Xceed] (had 1136 views)

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