B4J Question [SOLVED] FTP Commands

moore_it

Well-Known Member
Licensed User
Longtime User
Hi all,

i've a problem with FTP commands.
When i use the command RNFR and RNTO for move files from an ftp folder to another, not all files are moved.

I try to insert an sleep command but the problem remain

do you have any suggestions ?
 

teddybear

Well-Known Member
Licensed User
I guess you sent the RNTO command without waiting for RNFR to complete
 
Upvote 0

moore_it

Well-Known Member
Licensed User
Longtime User
i try this but not work


B4X:
FTP.SendCommand("RNFR",remotepath)
Dim sf As Object = FTP.SendCommand("RNTO",remotehstpath)
wait for (sf)  FTPLIST_CommandCompleted (Command As String, Success As Boolean, ReplyCode As Int, ReplyString As String)
 
Upvote 0

teddybear

Well-Known Member
Licensed User
i try this but not work


B4X:
FTP.SendCommand("RNFR",remotepath)
Dim sf As Object = FTP.SendCommand("RNTO",remotehstpath)
wait for (sf)  FTPLIST_CommandCompleted (Command As String, Success As Boolean, ReplyCode As Int, ReplyString As String)
What is the FTPLIST_CommandCompleted?
 
Upvote 0

teddybear

Well-Known Member
Licensed User
Try this
B4X:
Dim sf As Object = FTP.SendCommand("RNFR",remotepath)
wait for (sf)  FTPLIST_CommandCompleted (Command As String, Success As Boolean, ReplyCode As Int, ReplyString As String)
FTP.SendCommand("RNTO",remotehstpath)
 
Upvote 0

moore_it

Well-Known Member
Licensed User
Longtime User
Thanks for the help but it doesn't work, it downloads all the files but only moves three.
Not always though sometimes two sometimes four sometimes all of them.
 
Upvote 0

teddybear

Well-Known Member
Licensed User
Thanks for the help but it doesn't work, it downloads all the files but only moves three.
Not always though sometimes two sometimes four sometimes all of them.
You can only try to rename without downloading
 
Upvote 0

moore_it

Well-Known Member
Licensed User
Longtime User
yes now work

B4X:
Dim FTPDWN As FTP
                        FTPDWN.Initialize("FTPDWN",m.Get("d01"),m.get("d02"),m.Get("d03"),m.Get("d04"))
                        FTPDWN.PassiveMode = True
                        Dim sf As Object = FTPDWN.DownloadFile(remotepath,False,localpath,remotefile)
                        wait for (sf) FTPDWN_DownloadCompleted (ServerPath As String, Success As Boolean)
                        If Success Then
                            Log("download "&remotefile)
                            ' importo il file e lo cancello
                            ImportToDatabase(remotefile)
                            Log("importato "&remotefile)
                            ' scaricato correttamente sposto
                            Dim WO As Object = FTPDWN.SendCommand("RNFR",remotepath)
                            wait for (WO) FTPDWN_CommandCompleted (Command As String, Success As Boolean, ReplyCode As Int, ReplyString As String)
                            Dim WO As Object = FTPDWN.SendCommand("RNTO",remotehstpath)
                            wait for (WO) FTPDWN_CommandCompleted (Command As String, Success As Boolean, ReplyCode As Int, ReplyString As String)
                            Log("ridenominato "&remotefile)
                            MB00.SetMessage(fx.Colors.rgb(0,150,0),"File "&remotefile&" scaricato correttamente !",Chr(0xF071),True)
                        Else
                            MB00.SetMessage(fx.Colors.rgb(150,0,0),LastException.Message,Chr(0xF071),False)
                            Log(LastException.Message)
                        End If
                        FTPDWN.Close
ReplyReport Edit Delete
 
Upvote 0
Top