Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FtpGetCurrentDirectory Object reference error

Status
Not open for further replies.

JHPeter

Programmer
Apr 17, 2003
8
GB
Private Declare Function FtpGetCurrentDirectory Lib "wininet.dll" Alias "FtpGetCurrentDirectoryA" (ByVal hFtpSession As Integer, ByVal lpszCurrentDirectory As Sring, ByVal lpdwCurrentDirectory As Integer) As Boolean

Start New Function

Dim INn, INc
Dim RC As Boolean

INn = InternetOpen("FTP Control", 1, vbNullString, vbNullString, 0)
INc = InternetConnect(INn, " 21, "username", "password", 1, 0, 0)

sCurrDir = Space(255)
nCurrDir = Len(sCurrDir)

RC = FtpGetCurrentDirectory(INn, sCurrDir, nCurrDir)

This gives an Object reference not set to an instance of an object error, although FtpGetFile works Ok

Any assistance greatly appreciated
 
Hi,

The hFtpSession (1. parameter in the FtpGetCurrentDirectory call) should be the connection (INc) - you've put in the session (INn).
I would also recommend you to use option explicit, especially when using API calls.

Sunaj
'The gap between theory and practice is not as wide in theory as it is in practice'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top