Tilesoft
Member
Hi.
I use this code to download a file
But when run it, i get some errors. I attached errors photo.
I use this code to download a file
B4X:
Sub Button1_Click
Dim job As HttpJob
job.Initialize("j", Me)
job.Download("https://b4x-4c17.kxcdn.com/android/forum/data/avatars/m/0/1.jpg")
End Sub
Sub JobDone(job As HttpJob)
If job.Success Then
Dim out As OutputStream = File.OpenOutput(File.DirInternal, "number.jpg", False)
File.Copy2(job.GetInputStream, out)
out.Close '<------ very important
Log("number download done")
Dim number As Int
number = File.ReadString(File.DirInternal, "number.txt")
number = number+1
File.WriteString(File.DirInternal,"number.txt", number)
StartActivity(Post_Publish)
Else
Log("Error: " & job.ErrorMessage)
End If
job.Release
End Sub
But when run it, i get some errors. I attached errors photo.