在下面的代码中,如果搜索到的文件不存在,它仍然会尝试复制文件,指示说明文件是否在那里的逻辑,然后提取它,无法正常工作,我怎么可能解决这个问题?
Jar = AppData & ".technic\modpacks\" & Modpack & "\bin\modpack.zip"
ExtractTo = Temp
' If version.json already exists in Temp, get rid of it first.
If objFso.FileExists(Temp & "version.json") Then
objFso.DeleteFile(Temp & "version.json")
End If
' Fallback procedure, if errors occur and jar is still a ZIP, then skip this.
If objFso.FileExists(AppData & ".technic\modpacks\" & Modpack & "\bin\modpack.jar") Then
objFso.MoveFile AppData & ".technic\modpacks\" & Modpack & "\bin\modpack.jar", _
AppData & ".technic\modpacks\" & Modpack & "\bin\modpack.zip"
End If
' Open the ZIP and loop through to find the files we need.
Dim i
Set FilesInZip = objShellApp.NameSpace(Jar).Items
For i = 0 To FilesInZip.Count - 1
' If version.json is there, extract it to TEMP.
If FilesInZip.Item(i).Name = "version.json" Then
objShellApp.NameSpace(ExtractTo).CopyHere(FilesInZip.Item(i))
End If
' If forgeversion.properties is there, extract it to TEMP.
If FilesInZip.Item(i).Name = "forgeversion.properties" Then
objShellApp.NameSpace(ExtractTo).CopyHere(FilesInZip.Item(i))
End If
Next
我的事件序列如下:
这是我CopyFile
说明无法找到version.json
的时候。
它的目的是当无法找到文件时,生成对DOM的更新以声明No forge版本,而是尝试复制该文件,即使它不存在。
为什么会这样?