Android Question all FTP download files are completed.

Discussion in 'Android Questions' started by hub73, Mar 7, 2016.

  1. hub73

    hub73 Member Licensed User

    I download some files on my usb card from FTP. This is an folder and sub folders (recursive). All works fine. But now I just want display 'all finished' into my Label20a when all the FTP2_DownloadCompleted are completed...

    any idea ?

    Many thanks

    Here my code :

    Sub Recuperer_dossier_complet_nas ()
        FTP2.Initialize (
    "FTP2", EditText3a.Text, 21, EditText4a.Text, EditText5a.Text)
    If FTP2.IsInitialized = True Then
            Label20a.Text = 
    "Connexion FTP2 au NAS établie."
            Label20a.Text = 
    "Connexion FTP2 au NAS non établie !"
    End If
    end  sub

    Sub Copier_ce_fichier (CheminFichierComplet As String)

    Dim Origine As String
    Dim Destination As String
    Dim Nom_Fichier_destination As String
    Dim Chemin_destination As String

        Origine = CheminFichierComplet
        Destination = Dossier_destination_copie_nas & Origine.Replace (EditText11a.Text, 
        Nom_Fichier_destination = Destination.SubString2 (Destination.LastIndexOf (
    "/")+1, Destination.Length )
        Chemin_destination = Origine.Replace (EditText11a.Text, 
        Chemin_destination = Chemin_destination.SubString2 (
    0,Chemin_destination.LastIndexOf ("/")) & "/"

    File.MakeDir (Chemin_final_copie_dossier_nas, Dossier_destination_copie_nas & Chemin_destination)
        FTP2.DownloadFile (Origine, 
    False, Chemin_final_copie_dossier_nas & Dossier_destination_copie_nas & Chemin_destination, Nom_Fichier_destination)
        Label20a.Text = 
    "à copier '" & Origine & "'" 
    End Sub

    Sub FTP2_DownloadCompleted (ServerPath As String, Success As Boolean)
    'Log(ServerPath & ", Success=" & Success)
        'If Success = False Then Log(LastException.Message)
        If Success = True Then
            Label20a.Text =  
    "Fichier '" & ServerPath & "' téléchargé et copié."  
    End If
    End Sub   

    Sub FTP2_ListCompleted (ServerPath As String, Success As Boolean, Folders() As FTPEntry, Files() As FTPEntry)
    Dim Resultat As String
    If Success = False Then
    For i = 0 To Folders.Length - 1
                FTP2.List (ServerPath &  
    "/" & Folders(i).Name)
    For i = 0 To Files.Length - 1
                Resultat = ServerPath & 
    "/" & Files(i).Name
                Copier_ce_fichier (Resultat)
    End If

    End Sub
  2. DonManfred

    DonManfred Expert Licensed User
    See the methods in this thread. It may be of inspiration for you.

    The point is;

    You need to create a list for files you download.
    fill the list with all files to download and then download the first from the list.
    In the completed sub you then remove the first entry from this list and download the new first one.
    In the completed sub you then remove the first entry from this list and download the new first one.
    [and so on]
    If the list is empty then all files are downloaded
    Erel likes this.
  3. hub73

    hub73 Member Licensed User

    Perfect ! Many thanks !
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice