使用 VB6 +带 Windows 压缩的 WSH
WSH 和 Windows 压缩遇到问题。
我的目标是能够使用内置的 Windows 压缩功能压缩文件(不是文件夹,而是来自不同位置的单个文件,我将其存储在数组中)。我用的是VB6。
这是我的例程(vb6 代码):
Dim objShell
Dim objFolder
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.namespace(savePath & "\export.zip")
' --
' loop through array holding files to zip
For i = 0 To filePointer
objFolder.CopyHere (filesToZip(i))
Next
' --
Set objShell = Nothing
Set objFolder = Nothing
它可以工作,但是当文件数量较多时就会出现问题。 我开始从 Windows 中收到错误(大概是它调用压缩速度太快,并且 zip 文件被锁定)。我似乎无法弄清楚如何等待 COPYHERE 函数完成,然后再调用下一个函数以避免出现问题。
有人有这方面的经验吗?
谢谢 -
Having trouble with WSH and Windows Compression.
My goal is to be able to zip up files (not folders, but individual files from various locations, which I have stored in an array) using the built-in Windows Compression. I am using VB6.
Here is my routine (vb6 code):
Dim objShell
Dim objFolder
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.namespace(savePath & "\export.zip")
' --
' loop through array holding files to zip
For i = 0 To filePointer
objFolder.CopyHere (filesToZip(i))
Next
' --
Set objShell = Nothing
Set objFolder = Nothing
It works, but issues arise when there are more than a few files. I start getting errors from Windows (presumably, its calling the compression too fast, and the zip file is locked). I cant seem to figure out how to WAIT until the COPYHERE function completes before calling the next one to avoid issues.
Does anyone have any experience with this?
Thanks -
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在继续下一个循环迭代之前,您应该能够通过检查目标 ZIP 文件夹中的文件计数来实现这种同步(如建议的 此处和此处 >):
You should be able to achieve that sort of synchronization by checking the file count in your target ZIP folder before proceeding to the next loop iteration (as suggested here and here):