我有一个问题,我想在按下按钮后程序检查是否有文件在不同的位置(我使用的是if),如果这个文件不存在,我会下载它们(否则),下载后我会回到if并继续其余的代码。
If ComboBox2.SelectedItem = "1.12.2 Release" Then
If My.Computer.FileSystem.DirectoryExists(natives & "\1.12.2\natives") Then
launch = ("START CODE")
Shell("cmd.exe @echo off /c" & launch)
Me.Close()
Else
My.Computer.Network.DownloadFile("MY URL/natives.zip", natives & "\1.12.2\natives.zip")
System.IO.Compression.ZipFile.ExtractToDirectory(natives & "\1.12.2\natives.zip", natives & "\1.12.2")
My.Computer.FileSystem.DeleteFile(natives & "\1.12.2\natives.zip")
Return我想要在这段代码中添加更多内容,我想先做这件事,然后我留在了这里。在代码中,我只能看到5-7个要检查的文件夹中的一个
发布于 2019-12-26 04:55:30
创建以下逻辑
sub Main()
if not CheckFolders() then
if not DownloadFolders() then
MessageBox.Show("Can't start program")
Return
end if
end if
' Start your program here
end sub
function CheckFolders() as boolean
' check your folders here
end function
function DownloadFolders() as boolean
' download your folders here
end function这样,您就可以将检查文件/文件夹的逻辑与下载和启动逻辑分开。并且您可以按您希望的方式操作每个单独的组件
https://stackoverflow.com/questions/59481628
复制相似问题