CFtpClient::ChangeDirectoryUp Method  
 
INT ChangeDirectoryUp();

The ChangeDirectoryUp method changes directory to the parent of the current working directory.

Parameters

None.

Return Value

If the method succeeds, the return value is the server result code. If the method fails, the return value is FTP_ERROR. To get extended error information, call GetLastError.

Remarks

When using the FTP or FTPS protocols, this function sends the CDUP command to the server. This command is a special case of the CWD (Change Working Directory) command, and is included to simplify transferring between directory trees on those operating systems which have different syntaxes for naming the parent directory. The current user must have the appropriate permission to access the parent directory. On some systems, the user may be restricted to a specific directory tree (for example, through a chroot environment) or server configuration may prohibit navigating above a certain level. In these cases, the command may succeed without changing the current directory, or fail depending on the server implementation.

When using the SFTP protocol, there is no direct equivalent to the CDUP command. SFTP operates on fully qualified paths rather than maintaining a persistent current working directory on the server. To provide consistent behavior across protocols, this method simulates the command by normalizing the current path to its parent directory and storing it internally.

Because this behavior is implemented client-side, changing the working directory in an SFTP session does not affect the server state and is only meaningful within the context of the current connection. If the session is restricted to a specific directory (such as a chroot environment), attempting to navigate to a parent directory above that location will typically result in the path remaining unchanged. Additionally, permission-related errors may not be detected when this method is called. Instead, they may occur later when attempting to enumerate the directory or perform file operations within it.

Requirements

Minimum Desktop Platform: Windows 7 Service Pack 1
Minimum Server Platform: Windows Server 2008 R2 Service Pack 1
Header File: cstools11.h
Import Library: csftpv11.lib
Unicode: Implemented as Unicode and ANSI versions

See Also

ChangeDirectory, Command, GetDirectory, GetResultCode, GetResultString