FTP download problem

sheriffporter

Member
Licensed User
Longtime User
I am using an app to download files from a dir on my ftp server - then delete after download. I want the activity title to show the number of files left and I have a button that downloads them one at a time. The problem is that each time the download complete sub runs, it adds more to the list.size count so the count does not match the number of files. It gets higher even though I am removing files.
I cant seem to figure out how to get around this and make it show a correct count of the number of files left. Hope this makes sense, code below.

B4X:
Sub Ftp_ListCompleted (ServerPath As String, Success As Boolean, Folders() As FTPEntry, Files() As FTPEntry)
   
   For i = 0 To Files.Length -1   
      list1.Add(Files(i).Name) 
      Target = list1.size
         If myfile < list1.Size -1 Then  
         myfile = myfile + 1    
            Activity.Title = "             FILES WAITING ON SERVER  " & Target 
         End If
      Next
      File2Download = (list1.Get(myfile))
   FTP.DownloadFile(File2Download, False, File.DirRootExternal & "/inbox", File2Download)
      Wait(1)
   FTP.DeleteFile(File2Download)
End Sub
 
Top