Sub CheckVersion
Private cURL, cFile, cText, cTxtLast As String
cURL = "https://www.dropbox.com/s/ards6k5w3wuzy5n/version.txt?dl=1"
cFile = "version.txt"
wait for (DownloadAndSaveFile(cURL, Starter.SourceFolder, cFile)) Complete (Result As Boolean)
If Result Then
If File.Exists(Starter.SourceFolder, cFile) Then
cText = File.ReadString(Starter.SourceFolder, cFile)
cTxtLast = File.ReadString(Starter.SourceFolder, "last_" & cFile)
If cText == cTxtLast Then
lblMesg.Text = "Same Version"
Else
lblMesg.Text = "New Version Found : " & CRLF & "Old = " & cTxtLast & CRLF & "New = " & cText
Private cURL, cFile, cText As String
cURL = "https://www.dropbox.com/s/31w3ksayw80n6b8/b4xgoodies.html?dl=1"
cFile = "b4xgoodies.html"
wait for (DownloadAndSaveFile(cURL, Starter.SourceFolder, cFile)) Complete (Result As Boolean)
If Result Then
lblMesg.Text = lblMesg.Text&CRLF&"New Version downloaded"
End If
End If
End If
Else
MsgboxAsync("No internet connection" & CRLF & "or error downloading " & cFile, "Check Version")
End If
End Sub
Sub DownloadAndSaveFile(Link As String, cFolder As String, cOutPutFile As String) As ResumableSub
Dim oJob As HttpJob
oJob.Initialize("", Me)
oJob.Download(Link)
Log("oJob start ")
Dim result As Boolean = False
Wait For (oJob) JobDone(oJob As HttpJob)
Log("oJob.Success = " & oJob.Success)
If oJob.Success Then
Dim out As OutputStream = File.OpenOutput(cFolder, cOutPutFile, False)
File.Copy2(oJob.GetInputStream, out)
out.Close '<------ very important
Log($"${cOutPutFile} written to ${cFolder}"$)
result = True
End If
oJob.Release
Return result
End Sub