FTP & Net Lib in B4A 2.02, Issue?

margret

Well-Known Member
Licensed User
Longtime User
I have an issue using B4A 2.02 and the FTP net lib. I am writing a Class for FTP that I will share once I am done. All works fine so far but the Total in FTP_DownloadProgress always returns -1. I want to update a ProgressBar with the download but the Total is missing. I saw in the first post of this thread the code used is If Total > 0 Then. Is this an item that is returned from some servers and not others, etc. The TotalDownloaded is fine, it's just the Total that always returns -1. I can just skip the ProgressBar and continue on but I would like the ProgressBar option if there is a reliable way to get the Total value.

Code: Copy
Private Sub FTP_DownloadProgress (ServerPath As String, TotalDownloaded As Long, Total As Long)
    PB2.Visible = True
   PB2.BringToFront
   PB2.Progress = (100 / Total) * (TotalDownloaded)
End Sub
 
Last edited:
You will need to find the file size from the call to FTP.List.

When you say from the call to FTP, what are you refering to? I have no information about the files until the FTP_ListCompleted is finished as it places the file names in a list. The list has no information about the size of the files.
 
Upvote 0
When you say from the call to FTP, what are you refering to? I have no information about the files until the FTP_ListCompleted is finished as it places the file names in a list. The list has no information about the size of the files.
I think you should use ftpEntry afterwards.

Code: Copy
Sub FTP_ListCompleted (ServerPath As String, Success As Boolean, Folders() As FTPEntry, Files() As FTPEntry)
    Log(ServerPath)
    If Success = False Then
        Log(LastException)
    Else
        For i = 0 To Folders.Length - 1
            Log(Folders(i).Name)
        Next
        For i = 0 To Files.Length - 1
            Log(Files(i).Name & ", " & Files(i).Size & ", " & DateTime.Date(Files(i).Timestamp))
        Next
    End If
End Sub
That's from ftp tutorial.
 
Last edited:
Upvote 0
As far as I can see this is the only information that the function provides:

Code: Copy
Sub FTP_ListCompleted (ServerPath As String, Success As Boolean, Folders() As FTPEntry, Files() As FTPEntry)

Sorry, please check my updated post.
 
Upvote 0
Back
Top