Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
FtpSetCurrentDirectory error
Message
De
04/04/2007 17:55:35
Vernon Chambers
New York City Transit
New York, États-Unis
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
FtpSetCurrentDirectory error
Divers
Thread ID:
01212245
Message ID:
01212245
Vues:
58
Okay, this is driving me crazy!!!!

I have similar code in another application that works. However, the code below is giving me a "Data type mismatch" in the FtpSetCurrentDirectory function. What am I doing wrong?
****************************************************************
PROCEDURE vc_ftpget ( p_host, p_usr, p_pword, p_remotefil, p_destination, p_remoteloc )
***************************************************************
DECLARE INTEGER InternetOpen IN wininet.DLL;
	STRING sAgent, INTEGER lAccessType, STRING sProxyName,;
	STRING sProxyBypass, STRING  lFlags

DECLARE INTEGER InternetCloseHandle IN wininet.DLL INTEGER hInet

DECLARE INTEGER InternetConnect IN wininet.DLL;
	INTEGER hInternetSession, STRING  sServerName,;
	INTEGER nServerPort, STRING  sUsername,;
	STRING  sPassword, INTEGER lService,;
	INTEGER lFlags, INTEGER lContext

DECLARE INTEGER FtpGetFile IN wininet.DLL;
	INTEGER hFtpSession, STRING  lpszRemoteFile,;
	STRING  lpszNewFile, INTEGER fFailIfExists,;
	INTEGER dwFlagsAndAttributes,;
	INTEGER dwFlags, INTEGER dwContext

DECLARE INTEGER FtpSetCurrentDirectory IN wininet.dll; 
        INTEGER hFtpSession, STRING @lpszDirectory  

* server-side variable sAGENT is the target
sAgent = "vfp"

sProxyName = CHR(0)        && no proxy needed
sProxyBypass = CHR(0)    && nothing to bypass
lFlags = 0                && no flags used

* initialize access to Inet functions
hOpen = InternetOpen (sAgent, INTERNET_OPEN_TYPE_DIRECT,0,0,0)

IF hOpen = 0
	MESSAGEBOX( "Unable to get access to WinInet.Dll", 0, 'Comm error')
	RETURN
ENDIF

* connecting to the FTP
hFtpSession = InternetConnect (hOpen,  p_host,;
	INTERNET_INVALID_PORT_NUMBER,;
	p_usr, p_pword,;
	INTERNET_SERVICE_FTP, 0, 0)

IF hFtpSession = 0
	* close access to Inet functions and exit
	= InternetCloseHandle (hOpen)
	MESSAGEBOX( "Unable to connect to the selected FTP" , 0, 'Connect error')
	RETURN
ENDIF


IF !EMPTY( p_remoteloc )		&& set the correct directory for files
	IF FtpSetCurrentDirectory (hFtpSession, @p_remoteloc)
		MESSAGEBOX("Directory Found and Set",0,"OK",10)
	ENDIF
ENDIF

* downloading a file from the FTP
* no check whether the target file exists
lpszRemoteFile =  p_remotefil
lpszNewFile     =    p_destination

fFailIfExists  = 0        && do not stop if the target already exists
dwContext      = 0

lnResult = FtpGetFile (hFtpSession, lpszRemoteFile, lpszNewFile,;
	fFailIfExists, FILE_ATTRIBUTE_NORMAL, FTP_TRANSFER_TYPE_ASCII,;
	dwContext)


IF lnResult <> 1
	MESSAGEBOX( "Unable to download selected file", 0, 'Trouble')
ENDIF

* close handles
= InternetCloseHandle (hFtpSession)
= InternetCloseHandle (hOpen)

RETURN

ENDPROC
***********************************************************
Please help ... *smile*

Thanks in advance,

Vernon
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform