ReceiveFTPFile keeps failing in ver 5.40
Posted: Tue Oct 28, 2025 11:08 pm
Is it me? Usually is. No matter what I try I cannot get ReceiveFTPFile to to return positive when it downloads a specific file. I even created a loop to make 3 attempts and it still fails. What could I possibly be doing wrong? I know it is connecting ok because it always gives me that "Failed 3 times..." message. Here is my code:
The really goofy thing is... When I check my local directory, the new file is there, so the ReceiveFTPFile is working. Just not reporting positive when it is successful. Maybe a bug but I cannot use any other PB version to test that theory, because my code gets broken in a gazillion places and impossible to fix all the problems it creates.
Code: Select all
InitNetwork()
If OpenFTP(6, "ftp.Domain.com", USER$,FTPassword$,#True)
;ForEach fileList()
;f$ = fileList()
f$ = "CUSTOMER.ARC"
Debug f$
If FindString(LCase(f$),"customer.arc",#PB_String_NoCase)
cDate = GetFileDate(f$,#PB_Date_Modified)
; MessageRequester("Need Update", "Will attempt customer file download", #MB_OK|#MB_ICONINFORMATION)
EndIf
; Debug cDate
If LCase(f$) = "make1log.ex_"
; NEW VERSION UPDATE IS READY FOR ONELOOK (pending re-development)
EndIf
bad = #False ; TRUE if ReceiveFTPFile fails 3 times
attempt = 0
Repeat
attempt + 1
;SetGadgetText(#FTPstatus_0,f$+" download attempt #"+Str(attempt))
RecieveFailure = #False
If CheckFTPConnection(6)
If ReceiveFTPFile(6,f$,f$)
If FindString(LCase(f$),"customer.arc",#PB_String_NoCase)
If cDate <> GetFileDate(f$,#PB_Date_Modified)
cust = #True
Else
cust = #False
EndIf
EndIf
Else
Delay(800)
RecieveFailure = #True
EndIf
If attempt > 2 ;will attempt 3 times
bad = #True
badboy$ = f$
Break
EndIf
EndIf
Until bad = #True Or RecieveFailure = #True ;abandon retry if success or fail 3 times.
;Next
If bad
MessageRequester("Download Failed", "AutoFTP Failure -- Tried 3 times and could not perform "+badboy$+" download.", #MB_OK|#MB_ICONWARNING)
EndIf
CloseFTP(6)
Else
;SetGadgetText(#FTPstatus_0,"Cannot connect To server")
; Download unable to connect.
MessageRequester("FTP problem","Could not connect To server")
EndIf