Adding directoryPathInArchive in VBScript producing an error

Oct 1, 2010 at 7:00 PM

OK - the vbscript works great but when I had the directoryPathInArchive variable "home" I am getting an error.  Any suggestions appreciated.

dim filename 
filename = "C:\Temp\test.zip"

dim zip 
set zip = CreateObject("Ionic.Zip.ZipFile")
zip.Encryption = 3
zip.Password = "TEST"
zip.AddFile ("C:\Temp\test.xls","home")
zip.Name = filename
zip.Save()
zip.Dispose()
msgbox "Done"

Coordinator
Oct 5, 2010 at 1:24 PM
Edited Oct 5, 2010 at 1:26 PM
And the error is?? You stated that you get an error, but, ah...you didn't mention what the error is!

It's ok though; i've seen this situation before. I suspect you are encountering a vbscript syntax error; you must not use parenthesis to invoke a method that takes more than one parameter. Remove the parens on that line, and you may solve your problem.
Oct 5, 2010 at 1:45 PM

Thanks for the quick response. I suppose it would make your life easier if I posted the error message!  For some reason I can't add "home". Works great otherwise.

Error: Wrong number of arguments or invalid property assignment.

Here is the code: (that is a comma preceding "home" )

dim filename 
filename = "C:\Temp\test.zip"

dim zip 
set zip = CreateObject("Ionic.Zip.ZipFile")
zip.Encryption = 3
zip.Password = "TEST"
zip.AddFile "C:\Temp\test.xls", "home"
zip.Name = filename
zip.Save()
zip.Dispose()
msgbox "Done"

Coordinator
Oct 5, 2010 at 4:07 PM

Right -

I just remembered one additional thing.  VBScript uses COM to invoke .NET libraries. And COM doesn't support method overloading - you can't have a single method name with different variations, each of which accepts a different set of parameters.

So, you need to use a different name for the method.

AddFile_2 "c:\test", "home"

You can read more about this here: http://cheeso.members.winisp.net/DotNetZipHelp/Code%20Examples/COM.htm

Good luck.

 

Oct 5, 2010 at 4:13 PM

I read that article and was a little confused but it all makes sense now.

That did the trick!!! Many thanks for the quick response!

Coordinator
Oct 6, 2010 at 2:41 PM
Glad it helped!