Using the iFTPFileExist workaround the System is stable but regularly reports the FTP / Firewall issues.
So I thought I would try using the FTP LIST Command to get a full list of the Files in the Directory. The added bonus of this command is on our FTP Server this also returns the File Sizes so I can use this information instead of iFTPFileSize per File.
I have created this UDF to get this List:
#DefineFunction FtpListFileNames(ConHandle)
size = 65536
buf = BinaryAlloc( size )
;Get address of buffer
bufaddr = IntControl ( 42, buf, 0, 0, 0 )
BinaryEodSet( buf, size )
;PASV (recommended before calling LIST)
datahandle = iFtpCmd( conhandle, "PASV", "", @ASCII )
If datahandle == 0
Return
EndIf
;GET LIST
datahandle = iFtpCmd( conhandle, "LIST", "", @ASCII )
If datahandle == 0
Return
EndIf
count = iReadDataBuf( datahandle , bufaddr, size )
;Grab each file name
Start = 0
CRLF_Ptr = 0
FileList = ""
While CRLF_Ptr < count
CRLF_Ptr = BinaryIndex( buf, Start, @CRLF, @FWDSCAN)
If CRLF_Ptr == 0 then
Break
Endif
FileInfo = StrTrim(BinaryPeekStr( buf, Start, (CRLF_Ptr - Start)))
parsedata(FileInfo)
If Param3 <> "<DIR>" then
Size = Param3
Filename = ""
For A = 4 to Param0
Filename = StrCat(Filename, " ", Param%A%)
Next A
FileList = StrCat(FileList, @CRLF, Filename, @TAB, Size)
Endif
CRLF_Prt = CRLF_Ptr + 2
Start = CRLF_Prt
EndWhile
;Cleanup
BinaryFree( buf )
FileList = StrTrim(FileList)
Return FileList
#EndFunction
This works fine but when I call it a second time (within the same FTP Connection) it returns a empty FileList. I presume there must be an extra FTP Command I need to send before I can obtain the File List again?
Any ideas?
Thanks