Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
InternetWriteFile
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Divers
Thread ID:
00939833
Message ID:
00939902
Vues:
17
FUNCTION ftp2local (hConnect, lcSource, lcTarget)
	hTarget = FCREATE (lcTarget)
	IF (hTarget = -1) 
		RETURN -1
	ENDIF

	hSource = FtpOpenFile(hConnect, lcSource,;
		GENERIC_READ, FTP_TRANSFER_TYPE_BINARY, 0)
	IF hSource = 0
		= FCLOSE (hTarget)
		RETURN -2
	ENDIF

	lnBytesRead = 0
	lnChunkSize = 4096	&& 256, 512 and even 16384 are good
	
	DO WHILE .T.
		lcBuffer = REPLI (Chr(0), lnChunkSize)
		lnLength = Len (lcBuffer)
		IF InternetReadFile (hSource, @lcBuffer, lnLength, @lnLength) = 1
			= FWRITE (hTarget, lcBuffer, lnLength)
			lnBytesRead = lnBytesRead + lnLength
			?? "·"
			IF lnLength < lnChunkSize
				EXIT
			ENDIF
		ELSE
			EXIT
		ENDIF
	ENDDO

	= InternetCloseHandle (hSource)
	= FCLOSE (hTarget)
RETURN  lnBytesRead
Programming File Transfer Protocol in Visual FoxPro
http://www.news2news.com/vfp/?article=3
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform