Vilian
This is a working sample
My app uses ftp very intensively and it works OK.
FUNCTION RLOGTRN(TPAR,TFICLOG) // Récupérer FICHIERS LOGTRN QUI INDIQUENT CE QU'IL Y A à TéLécharger
LOCAL hInternet,DFIC,DFICL,DFICR, ;
I := 0, ;
J := 0, ;
DSITE := SPACE(100), ;
DUSER := SPACE(30), ;
DPASS := SPACE(10), ;
DDIR := SPACE(100), ;
HCON
local oInternet
local oFTP
local aFiles
DSITE := ALLTRIM(TPAR[08])
DUSER := ALLTRIM(TPAR[09])
DPASS := ALLTRIM(TPAR[10])
DDIR := ALLTRIM(TPAR[11])
oInternet := TInternet():New()
oFTP := TFTP():New( DSITE, oInternet, DUSER, DPASS )
if ! Empty( oFTP:hFTP )
aFiles = oFTP:Directory(DDIR)
endif
if ! Empty( oFTP:hFTP )
aFiles = oFTP:Directory( ddir + "LOGTRN*.*" )
endif
oInternet:End()
hInternet := InternetOpen( "Anystring", INTERNET_OPEN_TYPE_DIRECT, 0, 0, 0 ) // pocket connexion gprs
IF hINTERNET = 0
MSGINFO("ERREUR CONNEXION INTERNET")
RETURN NIL
ENDIF
hCon = INTERNETCONNECT( hInternet, DSITE,INTERNET_INVALID_PORT_NUMBER, DUSER, DPASS, INTERNET_SERVICE_FTP, 0,0 )
IF HCON = 0
MSGSTOP("Trop de connexion en cours, essayez plus tard !")
RETURN NIL
ENDIF
J := 0
FOR I = 1 TO LEN(AFILES)
IFILE := AFILES[I]
DFIC := ALLTRIM(IFILE[1])
IF SUBS(DFIC,1,1) = "." .OR. ASC(SUBS(DFIC,1,1)) = 0
ELSE
DFICL := CurDir() + "\ENTRANT\" + alltrim(dfic) // LOCAL FILE
DFICR := ALLTRIM(DDIR ) + alltrim(dfic) // REMOTE FILE
AADD(TFICLOG,DFIC) // STOCKER NOM FICHIER DANS TABLEAU POUR EFFACER APRES SYNCRO
FTPGETFILE( hCon, DFICR , DFICL, 0,FILE_ATTRIBUTE_ARCHIVE, 0, 0 )
ENDIF
NEXT
INTERNETCLOSEHANDLE( hCon )
INTERNETCLOSEHANDLE( hInternet )
return nil
PS : if you need other samples, please let me know
HTH
Richard
Ps : For ANTONIO
Enrico's sample is excellent but it will not work together with tftp class (using the same function names)