'This function uploads the files (stored in the list) to the server base'
Public Sub CaricaFoto
Log(filenamelist)
currentTotalFiles = filenamelist.Size
For Each filename In filenamelist
currentFileSize = File.Size(File.DirInternal & $"/${Starter.FileManager1.NomeCartella}"$, filename)
Dim sf As Object = FTP2.UploadFile(File.DirInternal & $"/${Starter.FileManager1.NomeCartella}"$, filename, False, $"${path}/${filename}"$)
Wait For (sf) ftp2_UploadCompleted (ServerPath As String, Success As Boolean)
If Success Then
LogColor("File Caricato", Colors.Green)
currentDoneFiles = currentDoneFiles + 1
'File.Delete(File.DirInternal & $"/${Starter.FileManager1.NomeCartella}"$, filename)
AggiornaProgress(Array As Object (0, currentDoneFiles, currentTotalFiles))
If currentDoneFiles == currentTotalFiles Then 'fine trasferimento
currentTotalFiles = 0
currentDoneFiles = 0
currentFileSize = 0
Log("TRASFERIMENTO COMPLETATO")
FTP2.Close
End If
Sleep(0)
End If
Next
End Sub
Private Sub ftp2_UploadProgress (ServerPath As String, TotalUploaded As Long, Total As Long)
If (TotalUploaded/currentFileSize)*100 > lastProgValue + 5 Then 'if incremented more than 5, i print
lastProgValue = (TotalUploaded/currentFileSize)*100
Log($"Filesize: ${currentFileSize}, Progress: ${lastProgValue}"$)
'AggiornaProgress(Array As Object (lastProgValue, currentDoneFiles, currentTotalFiles))
End If
End Sub
'This function update the UI'
Public Sub AggiornaProgress(Data() As Object)
'crcProgress.Value = Data(0) 'the value'
'lblCountingFile.text = $"${Data(1)}/${Data(2)}"$ 'uploadedsize/totalsize'
Sleep(10)
End Sub