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 Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with ftpsetcurrentdirectory command

Status
Not open for further replies.

lunchbox88

Programmer
Joined
Feb 17, 2004
Messages
208
Location
US
I can't seem to get this function to work, and I'm not sure what I'm doing wrong...

Here is the function declaration:

Code:
Private Declare Function FtpSetCurrentDirectory Lib "wininet.dll" Alias "FtpSetCurrentDirectoryA" (ByVal hFtpSession As Long, ByVal lpszDirectory As String) As Boolean

Here is my code calling that function:
Code:
RC = FtpSetCurrentDirectory(INetConn, "Folder2")

Every other piece of code is working fine. My connection is fine, etc... I just can't seem to get it to switch directories.

Any help is greatly appreciated
 
Try either
"\Folder2"
or
thefullpathonftp & "\Folder2"

the fullpathonptp not beeing a specifik command, its rather you making a string to were folder2 exists on ftp.

Also make sure you have the right access on the ftp

- - - - - - - - - - - - - - - - - -
Im three apples high, Im blue, and i most certainly like that cold beer that should be every mans right after a hard days work!
 
= MSDN said:
Remarks
An application should use the FtpGetCurrentDirectory function to determine the remote site's current working directory, instead of assuming that the remote system uses a hierarchical naming scheme for directories.

The lpszDirectory parameter can be either partially or fully qualified file names relative to the current directory. A backward slash (\) or forward slash (/) can be used as the directory separator for either name. FtpSetCurrentDirectory translates the directory name separators to the appropriate character before they are used.



- - - - - - - - - - - - - - - - - -
Im three apples high, Im blue, and i most certainly like that cold beer that should be every mans right after a hard days work!
 
The folder is right off the root folder, so it should be as simple as specifying "folder2" or even "/folder2", right?

I suppose I should implement FtpGetCurrentDirectory to make sure that I'm in root when I connect...

So...let me ask this, what's the quick way to implement FtpGetCurrentDirectory?
 
A word of advise, ditch the API calls and get a .Net FTP control. After a bit of searching and debating (APIs, COM, write our own, buy a pro tool, or use a freebie) we found this which is what we decided to use. I'm rather pleased with it. It's GPL, so free to use, but if you're distributing, you have to obide by the GPL.

-Rick

----------------------

[monkey] I believe in killer coding ninja monkeys.[monkey]
 
Maybe a bit OT, hope lunchbox88 doesnt mind.
Im not pro or con, but whats the downside with apis?
Im currently developing a small app that needs to transfer files to an ftp on regular basis. I do have a free ftpclass that works, but watching the example code that sunjab posted here earlier and lunchbox88 is using, im seriously thinking to abandon ftpclass and go winapi?
Im I stupid ? ;) Or is the winapi enough for a app thats just should be able to connect,change user and pwd and workdir and upload a unique file?


- - - - - - - - - - - - - - - - - -
Im three apples high, Im blue, and i most certainly like that cold beer that should be every mans right after a hard days work!
 
I don't mind the OT discussion.

I'm using the api because it's the easiest solution I've found. Granted, I'm still having a few problems with it.

I really just can't figure out why it won't let me change directories.

I'll keep looking for an implementation of FtpGetCurrentDirectory.
 
I guess it's a matter of preference. Some people will preach about "The future of coding" blah blah blah...

There's lots of little reasons, things like how long will the Win 32 API be supported (Which I beleive is going to be included in Longhorn, but not sure). What if the app needs to be ported to the web, or other OS (assuming MS ever impliments cross platform joy). What if the machine the app is on doesn't have the same version of the dll you are referencing? Is the code more complexe/harder to maintain becuase of the API?

Me personally, after years of duking it out with API calls, I'd gladly trade them in for a .Net object any day.

-Rick

----------------------

[monkey] I believe in killer coding ninja monkeys.[monkey]
 
Ok, I've tried everything I can think of, and nothing's working. I can connect to the FTP site just fine, but I can't get FtpSetCurrentDirectory function to work. Does anyone have any clue as to what I can check for?

Any help is greatly appreciated.
 
Ok, well, I finally decided to call err.LastDLLError, and it gave me 87. 87 is Error_Invalid_Parameter. Now, I just need to figure out which parameter is incorrect.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top