I try to develop a iOS application with Xojo but I have a problem when i try to download a file in special folder.
I made a new class (httpdw) from “xojo.net.HTTPSocket”
This is the code that i use:
CountProgress.Value = 0
dim weburl as text = "http://web1.website...../file.txt"
dim destinazione as FolderItem = SpecialFolder.Documents.Child("file.txt")
http = new httpdw
http.currentView = self
http.Send("GET", weburl, destinazione)
The file is downloaded but not completely. If I open the text file, I see that it is incomplete.
I’m following Xojo’s example, but I can not figure out where I’m wrong.
Can you help me?
http.Send is asynchronous, meaning it doesn’t wait for the transfer to complete before continuing to the next line of code. I suspect that the
http variable is going out of scope and gets destroyed while the transfer is in progress. Try making
http a property of the window; this will prevent it from going out of scope before the window is closed.
i’ve already set “http” for property of view. It is public.
So where is it that you’re checking that the file is not complete? I can see from your code that you’re requesting the file, but the call runs in the background from there and then fires the FileReceived event on the socket. Have you implemented that event somewhere?
Yes I do.
Hovewer I’ve solved. I think that a problem is a breakpoint during debug test. After I removed it, all work fine.
Thanks for you help!