Cannot Download Multipe Files Using FTP from Server to Device

Mahares

Expert
Licensed User
Longtime User
I would like to download certain number of files from PC to a device using FTP. I cannot get the Sub ftp_ListCompleted involved in the code( Java compile error). I would like to cycle through the server folder and download only the given files I want. Here is the code:

B4X:
Dim i , n As Short   'in global
Dim MyFile() As String   'in global
Dim DBfilePath as String   ' in global: This is location on device
Dim MyInitials as String   'in global

Sub btnDownload_Click
  MyInitials="XYZ"   
  FTP.List("Export")    'Export is the alias of the server folder containing the files
  FTP_ListCompleted("Export", True, "", "")   'Here is the big problem      
    For i = 0 To n - 1   'n is the total number of files in folder
      If MyFile(i).StartsWith("Base_") OR MyFile(i).StartsWith(MyInitials & "_")  Then  
         FTP.DownloadFile("Export/" & MyFile(i) , False, DBFilePath, MyFile(i))
      End If
    Next   
End Sub   


'BELOW LIST COMPLETED
Sub FTP_ListCompleted (ServerPath As String, Success As Boolean, Folders() As FTPEntry, Files() As FTPEntry)
       If Success = False Then
           Log(LastException)
       Else
           For i = 0 To Files.Length - 1
               MyFile(i)=Files(i).Name
               n=n+1
           Next
       End If
End Sub
Thank you very much
 

Mahares

Expert
Licensed User
Longtime User
The error is: Compiling generated java code on this line below:

B4X:
FTP_ListCompleted("Export", True, "", "")
Export is the alias of the server folder'
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
Please take a look at the code I have for the Sub FTP_ListCompleted . How do I then cycle through the files in the server and choose the ones I want to download to the device in this sub: Sub btnDownload_Click I did not understand your answer.
Thanks
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
To get the program to do what what I was trying to achieve, I needed to remove the line:
B4X:
FTP_ListCompleted("Export", True, "", "")

and call the download click button in activity resume for it to work:
B4X:
Sub Activity_Resume
      btnDownload_Click
End Sub
 
Upvote 0
Top