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.
http://www.jsware.net/jsware/scripts.php5#bints
It only requires Textstream, and includes functions
for reading file headers, like converting 4 bytes to
a 32-bit integer value.
For the format docs, it looks like this might be
sufficient:
http://en.wikipedia.org/wiki/ZIP_(file_format)
You can use the 'Shell.Application object on WinXP and newer to read the
contents of a zip file.
To get a listing of the files and folders at the root of the zip file, you
can use something like:
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sZipFile = "C:\TestFile.zip"
Set oShell = CreateObject("Shell.Application")
Set oZip = oShell.Namespace(sZipFile)
For Each oItem in oZip.Items
MsgBox oItem.Name, , oItem.Type
Next
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The folders should have a type of 'File Folder' and a size of 0. You can
enumerate the subfolders as well by appending their name to the zip file
itself. The one quirky thing I have found in experimenting (WinXP) with this
is that the first level subfolder off of the zip file must be delimited with
a backslash and 2nd level and deeper subfolders have to be delimited with a
forward slash. So if you have 'test.zip' with a folder called 'Level 1', you
would use 'test.zip\Level 1'. If you have a subfolder inside this one called
'Level 2', you need to use 'test.zip\Level 1/Level 2'. YMMV.