且构网

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

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

更新时间:2023-12-04 21:33:04

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

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

zipfile = "C:\path\to\your.zip"
fname   = "some.file"
dst     = "C:\some\folder"

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