Hi! I'm getting a strange problem when downloading multiple jpg files (1024 files) from a ftp server.
All the files are about 18 Mb, they are very small (200x200) jpg.
the problem is that after 150-170 files the download ends witohut any error.... sometimes at 150, sometimes at 155, and so on, never on the same file number.
I've used the file list event to write a small txt file in which every line is the name of the file to download. the file is correctly create and read (see scaricaimmagini sub)
After the download completed event, I started with the next file.
These are my subs:
Any idea? maybe an FTP server issue? (on the ftp server it is installed filezilla server)
regards
ciro
All the files are about 18 Mb, they are very small (200x200) jpg.
the problem is that after 150-170 files the download ends witohut any error.... sometimes at 150, sometimes at 155, and so on, never on the same file number.
I've used the file list event to write a small txt file in which every line is the name of the file to download. the file is correctly create and read (see scaricaimmagini sub)
After the download completed event, I started with the next file.
These are my subs:
B4X:
Sub BtnRicevi_Click 'ricezione dati
If FTPMode="L" Then
'File Locali
Dim Answ As Int
Answ=Msgbox2("Confermi Import Dati?",Main.nomeprog,"Anagrafiche","Annulla","Immagini",LoadBitmap (File.DirAssets, "warning_small.png"))
If Answ=DialogResponse.POSITIVE Or Answ=DialogResponse.NEGATIVE Then
If Answ=DialogResponse.POSITIVE Then
TipoImp="T"
Else
TipoImp="I"
End If
CircularProgressBar1.Value = 30
PopolaTabelle
End If
End If
If FTPMode="F" Then
'ftp
Dim server As ServerSocket 'Add a reference to the network library
server.Initialize(0, "")
If server.GetMyIP = "127.0.0.1" Then 'this is the local host address
'no connection
Msgbox2("Nessuna Connessione!",Main.nomeprog,"","Ok","",LoadBitmap (File.DirAssets, "warning_small.png"))
Else
Dim Answ As Int
Answ=Msgbox2("Confermi Import Dati?",Main.nomeprog,"Anagrafiche","Annulla","Immagini",LoadBitmap (File.DirAssets, "warning_small.png"))
If Answ=DialogResponse.POSITIVE Or Answ=DialogResponse.NEGATIVE Then
If Answ=DialogResponse.POSITIVE Then
TipoImp="T"
Else
TipoImp="I"
End If
TxtLog.Text=" "
Awake.KeepAlive(True) 'evitiamo lo stand by
LblStatus.Visible = True
TxtLog.Visible = True
BtnInvia.Enabled = False
BtnRicevi.Enabled = False
BtnExit.Enabled = False
'download immagini
'faccio pulizia prima di scaricare i files dall'FTP
TxtLog.Text = "Eliminazione files obsoleti..." &Chr(10)&TxtLog.Text
File.Delete(sdRoot,"listaimmagini.txt")
File.Delete(sdRoot&"/img/","*.jpg")
TxtLog.Text = "Connessione FTP "& FTPHost&"(" &FTPPort &") in Corso..." &Chr(10)&TxtLog.Text
CreaFileListaImmagini
End If
End If
End If
End If
End Sub
B4X:
Sub FTP_ListCompleted (ServerPath As String, Success As Boolean, Folders() As FTPEntry, Files() As FTPEntry)
Log(ServerPath)
If Success = False Then
Log(LastException)
Else
Dim j As Int
j=0
For i = 0 To Folders.Length - 1
Log(Folders(i).Name)
Next
Dim List1 As List
List1.Initialize
totimmagini=0
'ciclo per scaricare i files
For i = 0 To Files.Length - 1
Log(Files(i).Name & ", " & Files(i).Size & ", " & DateTime.Date(Files(i).Timestamp))
Log("/immagini/"&Files(i).Name&"-"&sdRoot&"/img/"&Files(i).Name)
' FTP.DownloadFile("/immagini/"&Files(i).Name, False, sdRoot&"/img/", Files(i).Name)
List1.Add(Files(i).Name)
File.WriteList(sdRoot,Nfile,List1)
totimmagini=totimmagini+1
Next
TxtLog.Text = "Creato File "&Nfile&Chr(10)&TxtLog.Text
'scarichiamo il primo file
numimmagine=1
Dim Reader As TextReader
Reader.Initialize(File.OpenInput(sdRoot, "listaimmagini.txt"))
Dim line As String
' Reader.ReadLine
line = Reader.ReadLine
FTP.DownloadFile("/immagini/"&line, False, sdRoot&"/img/", line)
End If
End Sub
B4X:
Sub FTP_DownloadCompleted (ServerPath As String, Success As Boolean)
Log(ServerPath & ", Success=" & Success)
If Success = True Then
'IMMAGINI
TxtLog.Text = "Download file "&ServerPath &" completato"&Chr(10)&TxtLog.Text
LblStatus.Text =numimmagine&"/"&totimmagini
If numimmagine = totimmagini Then
FTP.Close
CircularProgressBar1.Value = 100
Msgbox2("Ricezione completata!",Main.nomeprog,"","Ok","",LoadBitmap (File.DirAssets, "warning_small.png"))
TxtLog.Visible = False
LblStatus.Visible = False
Awake.ReleaseKeepAlive 'togliamo lo standby
BtnInvia.Enabled = True
BtnRicevi.Enabled = True
BtnExit.Enabled = True
Activity.Finish
StartActivity(Main)
Else
numimmagine = numimmagine +1
ScaricaImmagini ' devo scaricare altri files
End If
Else
Msgbox2("Errore nella Ricezione!",Main.nomeprog,"","Ok","",LoadBitmap (File.DirAssets, "warning_small.png"))
FTP.CloseNow
TxtLog.Visible = False
Awake.ReleaseKeepAlive 'togliamo lo standby
BtnInvia.Enabled = True
BtnRicevi.Enabled = True
BtnExit.Enabled = True
Activity.Finish
StartActivity(Main)
End If
End Sub
B4X:
Sub ScaricaImmagini
Dim Reader As TextReader
Reader.Initialize(File.OpenInput(sdRoot, "listaimmagini.txt"))
Dim i As Int
Dim line As String
' Reader.ReadLine
i=1
'Msgbox(numimmagine,"")
Do While i <= numimmagine
line = Reader.ReadLine
i=i+1
Loop
Log(numimmagine&"-"&line)
FTP.DownloadFile("/immagini/"&line, False, sdRoot&"/img/", line)
Reader.Close
End Sub
Any idea? maybe an FTP server issue? (on the ftp server it is installed filezilla server)
regards
ciro