如何在不实际提取文件的情况下使用 VBScript 读取 .zip 文件的内容? [英] How to read the contents of a .zip file with VBScript without actually extracting the files?

查看:40
本文介绍了如何在不实际提取文件的情况下使用 VBScript 读取 .zip 文件的内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个以父目录开头的 .zip 文件.我需要从文件中读取该目录,然后搜索我的 HD 以查看该目录名称是否已存在.如果存在,我将其删除并替换为 .zip 文件的内容.

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.

所有这些我都可以做,除了阅读 .zip 而不实际解压缩文件.

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

.zip 文件的大小可能超过 2G,所以我想避免解压缩,然后读取目录,然后复制.

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

我不直接解压缩到该位置并强制覆盖的原因是,由于某种原因,当使用 CopyHere 方法解压缩时,它忽略了通常会强制覆盖和仍然会提示用户是否要覆盖.

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.

解压文件的代码:

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

 objTarget.CopyHere objSource,4

推荐答案

假设你可以使用外部应用程序,尝试下载 7Zip 然后让您的脚本使用 -l 开关执行它.这应该会为您提供一些您应该能够以某种方式解析的输出.

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.

来自帮助文件的示例:7z l archive.zip

这篇关于如何在不实际提取文件的情况下使用 VBScript 读取 .zip 文件的内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆