Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to read the contents of a .zip file with VBScript without actually extracting the files?

Tags:

zip

vbscript

I have a .zip file that starts with a parent directory. I need to read that dir from the file then search my HD to see if that dir name already exists. If it exists, I then delete it and replace it the contents of the .zip file.

All of this I can do, except read the .zip without actually unzipping the file.

The .zip file can be upwards of 2G in size so I want to avoid unzipping, then reading the dir, then copying.

The reason I don't just unzip directly to the location and force an overwrite is that for some reason when using the CopyHere method to unzip, it ignores the switches that would normally force the overwrite and still prompts the user if they want to overwrite.

Code to unzip files:

 Set objSA = CreateObject("Shell.Application")
 Set objSource = objSA.NameSpace(pathToZipFile).Items ()
 Set objTarget = objSA.NameSpace(extractTo)     

 objTarget.CopyHere objSource,4
like image 209
ccwhite Avatar asked Jan 18 '11 12:01

ccwhite


1 Answers

Here is a similar question on SO.
How to list the contents of a .zip folder in c#?

I've used this library myself. It works well, http://dotnetzip.codeplex.com/, there is even a treeview example that appears to read the zip without extraction.

You will need the DLLs on the server, but I wouldn't say you have to install them. ;)

like image 98
Doug Chamberlain Avatar answered Oct 22 '22 05:10

Doug Chamberlain