Android Question when I download a file using ftp the ftp_downloaded event doesn't fire.

Patrick Fahey

Member
Licensed User
the process in question

Sub downloadfile
Log("downloadfile Files")
ftp.DownloadFile("/Sutherlin/download/live/routefile2.csv",False,File.dirrootexternal,"returncust2.txt")
ftp.DownloadFile("/Sutherlin/download/live/containfile2.csv",False,File.DirRootExternal,"returncont2.txt")
ftp.DownloadFile("/Sutherlin/download/live/notes2.csv",False,File.DirRootExternal,"returnnote2.txt")
ftp.DownloadFile("/Sutherlin/download/live/driver2.csv",False,File.DirRootExternal,"driver2.txt")
End Sub

Sub ftp_DownloadCompleted (ServerPath As String, Success As Boolean)
If Success = False Then
Log("FTP Error " & LastException.message)
ToastMessageShow("Error Downloading Data File",True)
Else
Log("FTP Sucess ")
Main.gooddownload = True
End If
End Sub
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
1) Use code tags!
2) How are you initializing your ftp object?
 
Upvote 0

Patrick Fahey

Member
Licensed User
This is how I initialized the FTP

B4X:
Sub ftpStart
    ftp.Initialize("ftp",Starter.sys_ftpsite,21,Starter.sys_ftpun,Starter.sys_ftppw)
    Main.ftpactive                     = ftp.IsInitialized
    If Main.ftpactive = False Then
        ToastMessageShow("FTP Failed to Initiailized",True)
        StartActivity(setup)
        ftp.Initialize("ftp",Starter.sys_ftpsite,21,Starter.sys_ftpun,Starter.sys_ftppw)
        Main.ftpactive                 = ftp.IsInitialized
        Log("ftp failed")
    Else
        Log("ftp Successed")
    End If
End Sub
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Start with this. Put this code in the starter service with your server parameters:
B4X:
Sub Process_Globals
   Private ftp As FTP
End Sub

Sub Service_Create
   ftp.Initialize("ftp", ...)
   Dim sf As Object = ftp.DownloadFile(...)
   Wait For (sf) ftp_DownloadCompleted (ServerPath As String, Success As Boolean)
   Log("download completed: " & Success)
   
End Sub

Does it work?
 
Upvote 0

Patrick Fahey

Member
Licensed User
This didn't work. I declared ftp in the starter module but was downloading in the utils module. the error I get is
Error description: Cannot assign void value.
Error occurred on line: 27
Dim sf1 As Object = Starter.ftp.DownloadFile("/Sutherlin/download/live/routefile2.csv",False,File.dirrootexternal,"returncust2.txt")
Word: )
B4X:
Sub downloadfile
    Starter.ftp.Initialize("ftp",Starter.sys_ftpsite,21,Starter.sys_ftpun,Starter.sys_ftppw)
    Log("downloadfile Files")
    Dim sf1 As Object = Starter.ftp.DownloadFile("/Sutherlin/download/live/routefile2.csv",False,File.dirrootexternal,"returncust2.txt")
    Wait For (sf1) ftp_DownloadCompleted (ServerPath As String, Success As Boolean)
    If Success Then
        Log("Customer file was download successfully")
    Else
        Log("Error download file")
    End If
    Dim sf2 As Object = Starter.ftp.DownloadFile("/Sutherlin/download/live/containfile2.csv",False,File.DirRootExternal,"returncont2.txt")
    Wait For (sf2) ftp_DownloadCompleted (ServerPath As String, Success As Boolean)
    If Success Then
        Log("Container file was download successfully")
    Else
        Log("Error Container file")
    End If
    Dim sf3 As Object = Starter.ftp.DownloadFile("/Sutherlin/download/live/notes2.csv",False,File.DirRootExternal,"returnnote2.txt")
    Wait For (sf3) ftp_DownloadCompleted (ServerPath As String, Success As Boolean)
    If Success Then
        Log("Note file was download successfully")
    Else
        Log("Error Note file")
    End If
    Dim sf4 As Object = Starter.ftp.DownloadFile("/Sutherlin/download/live/driver2.csv",False,File.DirRootExternal,"driver2.txt")
    Wait For (sf4) ftp_DownloadCompleted (ServerPath As String, Success As Boolean)
    If Success Then
        Log("Note file was driver successfully")
    Else
        Log("Error driver file")
    End If
End Sub
 
Upvote 0

Patrick Fahey

Member
Licensed User
Didn't work
B4X:
#Region  Project Attributes
    #ApplicationLabel: B4A Example
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Private ftp As FTP
End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")
    ftp.Initialize("ftp","mobilelogixs.com",21,"Patfahey","Truckuser!1")
    Dim sf As Object = ftp.DownloadFile("/sutherlin/download/live/routefile2.csv",False,File.dirrootexternal,"Returncust2.txt")
    Wait For (sf) ftp_DownloadCompleted (ServerPath As String, Success As Boolean)
    Log("download completed: " & Success)
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

My NET Library is Version 1.62
How do I get the latest net Library
 
Upvote 0

Similar Threads

Top