DotNetZip with classic ASP on Server 2003 64 bit

Nov 15, 2009 at 12:17 PM

After much fruitless searching, DotNetZip has turned out to be a cost effective solution to providing a simple Zip/Unzip COM solution for classic ASP pages on a Win2003 x64 platform. Having got it working I thought I should pass on a few tips so that others aren't faced with the same time consuming process that I was.

First - installation. The msi installer seemed unreliable so I simply got hold of the Ionic.Zip.dll component itself. It can be put in any location on the server, BUT the full path to that location must NOT contain any spaces. C:/MyFolder/Zip/Ionic.Zip.dll is OK, C:/My Folder/Zip/Ionic.Zip.dll is NOT. It's something the gacutil component doesn't like for some reason.

Second - configuration. You must have the .Net 2.0 SDK installed (and on this server it's the 64 bit version). The method that I found worked was to use the Command Prompt window and navigate (using the cd command) to the directory containing the gacutil.exe file. The full command is cd C:\Program Files\Microsoft.NET\SDK\v2.0 x64\Bin\ . From here execute the command on the Ionic.Zip.dll by entering gacutil.exe /i <full path to Ionic.zip.dll> In this example the full line would be gacutil.exe /i  C:/My Folder/Zip/Ionic.Zip.dll. You should get a success message. Do exactly the same to register the component with RegAsm. Once done, do NOT move the Ionic.zip.dll file or you'll have to go through this whole process again.

Third - usage. The documentation for using this component with classic ASP is very thin and you need to dig through the reference section and have some understanding of C# or VB.Net to work out the finer points of how all the methods can be used and the examples given are not altogether helpful.

To zip a number of files in a target directory and save them as a zip to another directory, this is what worked for me:

FileName="C:\MyFolder\ZippedFile"  '''The directory that will receive the finished zip file

PicsToZip="C:\MyFolder\PicsToZip"  ''The directory that contains pics to be zipped, i.e. MyPic1.jpg, etc

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

arrPics(0)="MyPic1.jpg'  

arrPics(1)="MyPic2.jpg'

arrPics(2)="MyPic3.jpg'     

For jj = 0 to UBound(arrPics)

          Zip.AddFile_2 "PicsToZip\"&arrPics(jj),""
Next
    
    Zip.Name=FileName
    Zip.Save()
    Zip.Dispose()
    Zip=nothing

Points to note here are that:

a) To add a file for zipping I found that the second overloaded method of AddFile was the only that would put the pics where I wanted them. As overloads don't work directly in COM mode, I had to use the 'mangled' description of the name (AddFile_2) which contains two arguments. By reference to the reference section I discovered these were string, string, the first being the file name, the second being the subdirectory in which they were placed. By setting this to "" pics were placed at the root level of the zip file. For some reason, if I used simply AddFile, the component created a set of sub directories corresponding to the file path.

b) Calling a method with two arguments in classic ASP is not like the documentation suggests. AddFile_2("FileName","DirectoryName") does not work. It has to be: AddFile_2 "FileName","DirectoryName" with no brackets.

Because my main purpose was to simply create a zip file I haven't investigated the rest of DotNetZip's functionality, but I think these pointers should be helpful - especially if somone can go through the whole of the methods and create a full classic ASP useage file.

Nov 15, 2009 at 7:52 PM

"Second - configuration. You must have the .Net 2.0 SDK installed"

I'm not sure the above is true, i just copied gacutil.exe from my local machine including the config file to my server and run it specifying the full path to the Ionic.zip.dll.....

not sure if directories with spaces cased an issue, i didn't have spaces

I thought the documentation was quite good - especially "DotNetZip can be used from COM Environments section", Its clear, com was a secondary feature added later, so still hoping for a proper type library to be exposed...........

 

Matt

Nov 16, 2009 at 8:27 AM

mlowne - you may right in saying that you can copy and paste the gacutil.exe with its configuration file straight onto the server. All I'm saying is that it comes with the .Net SDK and installing the SDK ensures that you get the right files in the right places - that goes for RegAsm too.

On the issue of file paths with spaces, this is really baffling. Using the gacutil.exe /i command with the full path to the Ionic.Zip.dll simply would not work if there were any spaces in the path to the dll. Try the command gacutil.exe /i C:/Program Files/...(and rest of path) and you get an error. Does anyone out there have an explanation?

On the COM implementation, yes I do realise that this is primarily a .Net component and it's very gratifying to have the extra COM functionality. However DotNetZip is a valuable resource for those of us who have to maintain legacy classic ASP sites so I hope that we will be able to share as much info in the way of hints and tips on how to use it in this way. Although I'm not a PHP programmer, I dare say the PHP community may also welcome a parallel sharing of information.

Coordinator
Nov 16, 2009 at 11:36 AM

Stuart -

yes I have an explanation.  If you are running things from the cmd prompt, then you need to surround paths that have spaces, in double-quotes. This goes for the program you are invoking, as well as any argument to the program.  So in the example of gacutil, if gacutil were installed in a path that had spaces, and if the DLL you were installing in the gac had spaces in its path, then both would need the double-quotes.

"c:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\bin\gacutil.exe" -i 
    "c:\Program Files\Dino Chiesa\DotNetZip v1.9\Ionic.Zip.dll" 

(all on one line)

thanks for the feedback - very helpful.

Coordinator
Nov 16, 2009 at 11:36 AM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Nov 16, 2009 at 1:46 PM
Hi Cheeso,

Well I never knew that :) .... although my experience at running
commands from the cmd prompt is somewhat limited - many thanks for the
information.

Oh... and great work on the DotNetZip component itself especially the
COM interoperability. It got me out of a big hole when moving servers
from a 32 bit to 64 bit edition.

All the best


Stuart

Cheeso wrote:
>
> From: Cheeso
>
> Stuart -
>
> yes I have an explanation. If you are running things from the cmd
> prompt, then you need to surround paths that have spaces, in
> double-quotes. This goes for the program you are invoking, as well as
> any argument to the program. So in the example of gacutil, if gacutil
> were installed in a path that had spaces, and if the DLL you were
> installing in the gac had spaces in its path, then both would need the
> double-quotes.
>
> "c:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\bin\gacutil.exe" -i
> "c:\Program Files\Dino Chiesa\DotNetZip v1.9\Ionic.Zip.dll"
>
> (all on one line)
>
> thanks for the feedback - very helpful.
>
> Read the full discussion online
> <http://dotnetzip.codeplex.com/Thread/View.aspx?ThreadId=75174&ANCHOR#Post257469>.
>
> To add a post to this discussion, reply to this email
> ([email removed]
> <mailto:[email removed]?subject=%5BDotNetZip:75174%5D>)
>
> To start a new discussion for this project, email
> [email removed]
> <mailto:[email removed]>
>
> You are receiving this email because you subscribed to this discussion
> on CodePlex. You can unsubscribe
> <http://www.codeplex.com/site/discussions/thread/unsubscribe/75174> on
> codePlex.com.
>
> Please note: Images and attachments will be removed from emails. Any
> posts to this discussion will also be available online at codeplex.com
>

--
---------------------------------------------------------------------------
Stuart Dollin
Lead Developer and Head of IT
Autoweb Ltd
01757 701010