Cannot set CompressionLevel Property

Jul 19, 2012 at 11:25 AM

I have the following code that works fine:

<%@LANGUAGE=VBScript%>
<%
'On Error resume Next
Server.ScriptTimeout=100000
Response.Write("Processing C")
Response.Buffer = true
Response.Expires = 0

Response.Write("Processing 1")

dim zip
Set zip = CreateObject("Ionic.Zip.ZipFile")

zip.AddFile("C:\TEST_SOURCE\1.mp4")
zip.AddFile("C:\TEST_SOURCE\2.mp4")
zip.AddFile("C:\TEST_SOURCE\3.mp4")
zip.AddFile("C:\TEST_SOURCE\4.mp4")
  
zip.Name="C:\TEST_DEST\zipfile.zip"
zip.Save()
zip.Dispose()
  

%>

But if I add in a line to set the "Compression Level" like this:

<%@LANGUAGE=VBScript%>
<%
'On Error resume Next
Server.ScriptTimeout=100000
Response.Write("Processing C")
Response.Buffer = true
Response.Expires = 0

Response.Write("Processing 1")

dim zip
Set zip = CreateObject("Ionic.Zip.ZipFile")

zip.CompressionLevel = "None"

 
zip.AddFile("C:\TEST_SOURCE\1.mp4")
zip.AddFile("C:\TEST_SOURCE\2.mp4")
zip.AddFile("C:\TEST_SOURCE\3.mp4")
zip.AddFile("C:\TEST_SOURCE\4.mp4")
  
zip.Name="C:\TEST_DEST\zipfile.zip"
zip.Save()
zip.Dispose()
  

%>

I get an error. 

Processing CProcessing 1Processing 2

Microsoft VBScript runtime error '800a01ae'

Class doesn't support Automation: 'CompressionLevel'

/asp/test_2.asp, line 20

Can anyone please help? - I need to turn compression off as I am zipping already compressed files.


Jul 20, 2012 at 6:19 PM
PGh0bWw+PGhlYWQ+PC9oZWFkPjxib2R5IGJnY29sb3I9IiNGRkZGRkYiPjxkaXY+SGksPC9kaXY+ PGRpdj48YnI+PC9kaXY+PGRpdj5JJ20gbm90IG5lYXIgYSBjb21wdXRlciByaWdodCBub3cgdG8g Y2hlY2ssIGJ1dCBJJ20gcHJldHR5IHN1cmUgQ29tcHJlc3Npb25MZXZlbCBpcyBhbiBlbnVtLCBz byB5b3UnbGwgbmVlZCB0byBzcGV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9OVD48L1NQQU4+PC9GT05UPjwvRk9OVD48QSB0aXRsZT0iZ2ZpZGlzYy53 ZWJpbnRlZ3JhdG9ycy5jby51ayIgaHJlZj0iIyI+ICA8L0E+PC9ib2R5PjwvaHRtbD4--Apple-Mail-4C0DA2A9-72EE-4F63-A43F-5FC6C9FF782D--
Jul 20, 2012 at 11:32 PM

CompressionLevel is not a string. Use this:

 

Ionic.Zlib.CompressionLevel.None

Jul 21, 2012 at 9:17 AM

Apologies for the spam in my last post - I replied to the alert email using an iPhone, and codeplex obviously doesn't like that.

My reply was basically the same as Aerowinder, except I'm not totally convinced that VBScript will import the enumeration values from the .Net library so you might need to use the numeric value of the enum.

 

zip.CompressionLevel = 0

 

or better yet declare a constant so you don't have magic numbers lying around:

 

const ZipCompressionLevelNone = 0

zip.CompressionLevel = ZipCompressionLevelNone

 

Hope this helps,

M

Jul 22, 2012 at 7:08 PM

Thanks Aerowinder, Pointy.

The solution as provided by pointy works great, as you say the VB script does not import the enumeration values from the library (at least not when notepad is your dev environment!)