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

前端 未结 4 1858
离开以前
离开以前 2021-01-18 07:36

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

相关标签:
4条回答
  • 2021-01-18 08:09

    I'm not sure if it is possible to read the contents of a zip without extracting it.

    If you are just trying to avoid a time consuming copy operation on the data you could try unzipping to a temp directory and then using a "move" function. Move is usually less time consuming than copy as it doesn't actually re-write the data on the disk. It just updates the file system to point at where the data is.

    0 讨论(0)
  • 2021-01-18 08:20

    Assuming that you can use an external application, try downloading 7Zip and then have your script execute it with the -l switch. This should give you some output that you should be able to parse in some way.

    Sample from the help file: 7z l archive.zip

    0 讨论(0)
  • 2021-01-18 08:22

    You can use For Each on your objSource object, for example:

    Dim objSA, objSource, item
    Set objSA = CreateObject("Shell.Application")
    Set objSource = objSA.NameSpace(pathToZipFile).Items ()
    For Each item in objSource
        WScript.Echo item
    Next 
    
    0 讨论(0)
  • 2021-01-18 08:29

    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. ;)

    0 讨论(0)
提交回复
热议问题