In the below code, if the files being searched for are not present, it still tries to copy the file, indicating that the logic to say if the file is there, then extract it, fails to work correctly, how may I fix this?
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
My sequence of events are this:
- I open my app, it detects as it is supposed to that the forge file exists and has a version.
- I delete the jar/zip and then put a fresh one in without the files the function tries to find.
- I press the refresh link in the app to run the above function again.
This is when I get CopyFile
stating the version.json
could not be found.
It's intended function is to when not able to find the files, produce an update to the DOM to state No forge version, but instead tries to copy the file even though it isn't there.
Why is this happening?