Access to existing compression/encryption settings


#1

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


#2

Another thought is if there’s an “Update” or “Replace” method, like the “UpdateEntry” method that’s available in DotNetZip, documented here: https://documentation.help/DotNetZip/8e97c2ad-5d61-7aec-f71e-3d5c186973ab.htm

Thanks,
Michael Whalen


#3

@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.


#4

@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.


#5

Great - thanks for the quick turnaround.


#6

@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)


#7

It works perfectly - thanks again!

– Michael Whalen