How to change directories

While you are connected to an FTP server, the server keeps track of your working directory. The server assumes you are referring to this directory whenever you perform a file operation without specifying an absolute path. In fact many FTP servers do not support the use of absolute paths.

The current working directory is available by calling the pwd() method:

string directory = ftp.pwd();

This may be changed using:

ftp.chdir(directory);

Or to simply go up to the parent directory:

ftp.cdup();

All methods described above are supported in the FTPClient, SSLFTPClient, ProFTPClient and SSHFTPClient classes.