Zip “Save As” when Unzipping

Question:

I have a need to unzip files from zip files created with Chilkat library, but I would like the library to allow me to specify the ‘SaveAs’ name of the file being unzipped.  I have not seen how to do this in the examples or the API documentation.
Could you provide any insight into this for me?  I saw that I can rename a file within a zip file, and then call WriteZip, but I figure there might be a better approach?  I could also extract with the name the file was zipped with, and then do OS rename, but this is not ideal.  My application would really then need to unzip into a temp directory to ensure there are no filename conflicts, and then copy to the target location which may be on a different hard drive,  thus providing large time penalty to my end user.
Answer:
After you open a .zip by calling a method such as OpenZip, you may modify the FileName property of any of the contained ZipEntry objects.  When you unzip, the current value of each ZipEntry’s filename property is used.  For example:
(Consider this as pseudo-code...)

bool success = zip.OpenZip("something.zip");
// You would normally check the success, but not for this example...

Chilkat.ZipEntry entry = zip.FirstMatchingEntry("*hamlet.xml");
// You would normally check for NULL...

entry.Filename = "ShakespearePlay.xml";

int numFilesUnzipped = zip.Unzip("c:/unzipDir");
Tags :