Archived Forum Post

Index of archived forum posts

Question:

How to Change the Name of the File Added to a Zip?

Mar 01 '13 at 10:45

I would like a new method that would allow you to add a file to the zip but also specify a different file name. For example I have a file called "abc_20130212.dbf" and when I add it to the zip I would like to be able to change the name in zip file to "abc.dbf" and that would then be the name it has when extracted.

Currently I do this using the AppendData method which requires an extra step of converting the file to data first then adding it to the zip. I would just like to be able to do this in one step and avoid the converting to data step.


Answer

No new feature is necessary.

After entries have been added to the Chilkat.Zip object via any of the Append* methods, each entry can be retrieved and the Chilkat.ZipEntry.FileName property may be changed prior to writing the .zip. The Chilkat.ZipEntry still references the file in the filesystem that is to be included in the .zip when WriteZip* is called, but the filename used within the .zip will be the current value of the ZipEntry.FileName property.