Access, Reuse Existing Compression/Encryption Settings

Is there a way to access the existing CompressionSettings/ExceptionSettings properties of an ArchiveEntry object? Our process takes an existing file from an ArchiveEntry, makes some modifications, and then attempts to replace it in the zip archive, and we need the replacement entry to use exactly the same compression and encryption settings. We will have the password used to create the entry in the first place, we just won’t know what type of encryption was used, nor what level of compression and the other things stored in those values.

Thanks for any info on this,
Michael Whalen

Another thought is if there’s an “Update” or “Replace” method, like the “UpdateEntry” method that’s available in DotNetZip, documented here: UpdateEntry Method - DotNetZip Documentation

Thanks,
Michael Whalen

@mwhalen

We have logged your requirements with ID “ZIPNET-282” and ID “ZIPNET-283” for further investigation. You will automatically be informed here once we have more information to share.

@mwhalen
Hello Michael,
Tomorrow we will provide you with a modified 18.11.1 version having compression and encryption settings exposed for an entry. Those changes will also be included in upcoming 18.12 version alongside with new features.

Great - thanks for the quick turnaround.

@mwhalen

Hello Michael, please find the modified version attached.
Below is the sample code that reuses settings of excluded entry at index 0 to appended one.

using (Archive archive = new Archive("arch.zip"))
{
    CompressionSettings compressionSettings = archive.Entries[0].CompressionSettings;
    EncryptionSettings encryptionSettings = null;
    if (archive.Entries[0] is ArchiveEntryEncrypted)
    {
        encryptionSettings = ((ArchiveEntryEncrypted)archive.Entries[0]).EncryptionSettings;
        encryptionSettings.Password = "p@s$";
    }
    archive.DeleteEntry(archive.Entries[0]);
    archive.CreateEntry("newfile.txt", File.OpenRead("newfile.txt"), new ArchiveEntrySettings(compressionSettings, encryptionSettings));
    archive.Save("modified.zip");
}

Please update to 18.12 version when it become ready.
Aspose.ZIP_18.11.1.zip (2.0 MB)

It works perfectly - thanks again!

– Michael Whalen