且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用 VBScript 从 zip 中删除文件

更新时间:2023-12-04 21:32:28

使用 MoveHere 方法将项目移出 zip 文件:

Use the MoveHere method to move an item out of the zip file:

zipfile = "C:path	oyour.zip"
fname   = "some.file"
dst     = "C:somefolder"

Set app = CreateObject("Shell.Application")
For Each f In app.NameSpace(zipfile).Items
  If f.Name = fname Then
    app.Namespace(dst).MoveHere(f)
  End If
Next

然后从dst文件夹中删除文件:

Then delete the files from the dst folder:

Set fso = CreateObject("Scripting.FileSystemObject")
fso.DeleteFile fso.BuildPath(dst, fname), True