Android Question FTP Vb.NET y B4A

Bladimir Silva Toro

Active Member
Licensed User
Longtime User
Hi

I want to learn how to make a copy of a file to an FTP, I want that when for example the file is 40 MB and the FTP has already been uploaded 20 MB, it will inform me in a progress bar that goes to 50%.

I need to do this in Vb.NET and in B4A, can someone help me out?

Thank you.
 

Brian Dean

Well-Known Member
Licensed User
Longtime User
I think that Erel misunderstood your question. When you start an FTP job you can include an event handler that will get called with progress status, something like this ...

B4X:
Sub Class_Globals
    Dim FTP as FTP
    Dim filesize as Long
End Sub

Sub uploadFile(dir As String, filename As String, hostPath as string)
    filesize = Round(File.Size(dir, filename))
    FTP.UploadFile(dir, filename, False, hostPath)
End Sub

Sub FTP_UploadProgress(hostPath As String, TotalUploaded As Long, Total As Long)
    Log("Uploading..." & Round(TotalUploaded / filesize * 100) & "%")   
End Sub

Sub FTP_UploadCompleted(hostPath As String, Success As Boolean)
    If Success Then
        Log("Finished")
    Else   
        Log("Failed")
        Log(LastException.Message)
    End If
End Sub

This is not tested code, by the way, but a guide to what I hope you are looking for, unless I have misunderstood your question.
 
Upvote 0
Top