+2 votes

My remote ftp server directory is "/". I tried to change it to "D:\FTP\INPUT" to download files but I received The parameter is incorrect error. Could you please guide me for the correct syntax of client.ChangeFolder() method? Thank you so much.

by
retagged by

1 Answer

0 votes

Most (all) FTP servers don't allow using absolute path that includes drive letter to represent files/folders on the server.

The error you get is not raised by the FTP component, but by the server itself.

Usually FTP server is configured in such way that the root server path ("/") is internally mapped to specific location on disk (e.g. "d:\data\ftp\user1\").

You can use Ftp.ChangeFolder to change the current path, but not to change the root server path (that would introduce huge security risk - imagine changing the path to "c:\windows" folder).

To put it simply: Ftp.ChangeFolder can be used to move around inside the root path ("d:\data\ftp\user1\"), for example, when current folder is root, invoking:

ftp.ChangeFolder("folder1");

changes the actual folder to "d:\data\ftp\user1\folder1", then invoking:

ftp.ChangeFolder("subfolder");

changes the actual folder to "d:\data\ftp\user1\folder1\subfolder", then invoking:

ftp.ChangeFolder("/folder2");  // note the slash

changes the actual folder to "d:\data\ftp\user1\folder2".

by (297k points)
...