FtpChangeClientDirectory Function  
 
BOOL WINAPI FtpChangeClientDirectory(
  HSERVER hServer,  
  UINT nClientId,  
  LPCTSTR lpszDirectory  
);

Change the current working directory for the specified client.

Parameters

hServer
The server handle.
nClientId
An unsigned integer which uniquely identifies the client session.
lpszDirectory
A null-terminated string which specifies the new current working directory for the client session. If this parameter is NULL or an empty string, the current working directory will be changed to the client home directory. If this parameter is not NULL, it must specify a directory that exists and is accessible by the server process.

Return Value

If the current working directory was changed, the return value is non-zero. If the server handle and client ID do not specify a valid client session, or the directory is invalid, this function will return zero.

Remarks

The FtpChangeClientDirectory function will change the current working directory for the specified client session. This function is called internally when the client sends the CWD or CDUP commands, however it may be explicitly used by the application to change the client's working directory in response to a server event.

This function cannot be used to change the current working directory for a client to an arbitrary directory outside of the server root directory. If the lpszDirectory parameter specifies a relative path (i.e.: a path that does not begin with a drive letter or leading path delimiter) then the new working directory will be relative to the current working directory. If an absolute path is specified, the absolute path must include the complete path to either the server root directory or the user's home directory, based on the permissions granted to the client session. If a path outside of the server root directory is specified, this function will fail with an access denied error.

Use caution when calling this function to override the directory specified by the client when it sends the CWD or CDUP commands. If your application changes the current working directory to one not specified by the client, it may cause unpredictable behavior in the client application because the actual path of the current working directory will not match the directory that was requested.

If this function is used to change the current working directory in response to the CWD command, you should not call the FtpGetCommandParam function and pass the command parameter as an argument to this function. You must use the FtpGetCommandFile function to obtain the directory name provided by the client prior to calling this function.

The application should never call the SetCurrentDirectory function in the Windows API to change the current directory for the process to the working directory of a client session. Because the server is multithreaded and each client session is managed in its own thread, an application using this library should avoid using relative paths.

Requirements

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

See Also