Changing directories with FtpSetCurrentDirectory
Posted on 2008-10-22
I'm having a problem using this Microsoft WinInet function in my PB Code. Here is what's happening:
I successfully FTP into a server with that has 2 subfolders under the root, lets call the 2 subfolders Images and Items so it looks like this:
//(Root where I'm at after first FTP'ing in)
I can use FtpSetCurrentDirectoryA to go to the Items folder then I FTP some data, that works. The problem is how do I change to the Images folder from the Items folder??. I cant go directly to the folder and I cant seem to figure out how to go up one level or go to the root. I've tried calling my function like this while in the Items folder:
li_rc = FtpSetCurrentDirectoryA( iul_service, 'Images' ) == Return code error
li_rc = FtpSetCurrentDirectoryA( iul_service, ' ..' ) == Tried Space + period + period to go up one directory still get error.
Of course If I completly disconnect then reconnect to the server I'm placed in the root and I can then go there but I shouldn't have to disconnect from the FTP and come back in just to go to a different directory.
I thought if maybe I use FtpGetCurrentDirectoryA when I first come in maybe I can read the name of the root directory so I can know the name to pass to FtpSetCurrentDirectoryA later on but I can't get this function to work. Here is my code that calls this function but I keep getting an error saying %s Invalid Parameter or something when I call it, here is my code for that.
String ls_dir, ls_dir2
CONSTANT uint MAX_PATH = 254
lul_mode = MAX_PATH
lb_rtn = FtpGetCurrentDirectoryA( iul_service,ls_dir,lul_mode)
iul_errorcode = GetLastError()
IF NOT lb_rtn THEN
Prototypes for both functions:
FUNCTION ulong FtpSetCurrentDirectoryA( ulong hService, string szPath ) LIBRARY "wininet.dll" alias for "FtpSetCurrentDirectoryA;Ansi"
FUNCTION boolean FtpGetCurrentDirectoryA( ulong hService, string szCurrentDirectory, ulong dwCurrentDirectory) LIBRARY "wininet.dll" alias for "FtpGetCurrentDirectoryA;Ansi"