Italian Errore di inizializzazione lista FTP

francesco paolo lavecchia

Member
Licensed User
Ciao a tutti,

il codice sotto (copiato da un esempio di Erel) mi da questo errore:

(RuntimeException) java.lang.RuntimeException: Object should first be initialized (List).

Quale lista devo inizializzare?

Grazie

B4X:
Dim ftp As FTP

 ftp.Initialize("FTP", "server", 21, "user", "password")
 ftp.PassiveMode = True
 ftp.List("/")


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
 

LucaMs

Expert
Licensed User
Longtime User
B4X:
   FTP.List("/UnaMiaDirectory")
   Wait For FTP_ListCompleted (ServerPath As String, Success As Boolean, Folders() As FTPEntry, Files() As FTPEntry)
   If Success Then
       Log("List completato correttamente")
       Log("Server path: " & ServerPath)
       For i = 0 To Files.Length - 1
'           Log(i & TAB & Files(i))
       Next
   Else
       Log("List fallito")
       Return
   End If
 

Sagenut

Expert
Licensed User
Longtime User

Sagenut

Expert
Licensed User
Longtime User
Non credo che sia importante ma prova a cambiare la riga così
B4X:
Sub ftp_ListCompleted (ServerPath As String, Success As Boolean, Folders() As FTPEntry, Files() As FTPEntry)
in pratica con ftp minuscolo in ftp_ListCompleted
Non penso che sia Case Sensitive però costa niente provare.
 

LucaMs

Expert
Licensed User
Longtime User
Per favore mi puoi inviare un esempio completo (ovviamente senza server,user e pwd ;)) che a te funziona al 100%?
Quello che ho pubblicato era una prova; subito dopo quel codice mi serviva fare una prova, rinominare un file sul server. La prova ha funzionato ed anche quella parte, il List FTP (anche perché altrimenti sarebbe stato eseguito il Return e non il cambiamento del nome del file).
 

Sagenut

Expert
Licensed User
Longtime User
Ci mancavano anche questi dubbi.
Non c'è pace per gli Sviluppatori.
 
Top