Save method and existing ZIP

Apr 1, 2010 at 5:35 PM
Edited Apr 1, 2010 at 5:36 PM

I am using DotNetZip with a classic ASP application and I got this error when I generated the same name zip file more than once:

mscorlib error '800700b7'

Cannot create a file when that file already exists

even though the Save method documentation says

If necessary, this method will delete a pre-existing file before the rename.

Here's my code:

Dim zip
Set zip = Server.CreateObject("Ionic.Zip.ZipFile")
strFileName = Dir & "\"
zip.Name = strFileName

As you can see, I am adding a folder to the ZIP and saving it.  I can delete the existing file before I save, but the documentation says it will do it for me.

Apr 1, 2010 at 8:26 PM

Yes, there's definitely a problem there.

At one time the documentation was consistent with the code, but at some point someone asked for the behavior to be changed , and then I forgot to update the doc.

So, easy workaround:  delete the file first.

In the future, I'm going to expose an option to the Save method that will specifiy that existing files should be overwritten. 

In the meantime I should fix the doc.