CFtpServer::GetCommandFile Method  
 
INT GetCommandFile(
  UINT nClientId,  
  LPTSTR lpszFileName,  
  INT nMaxLength  
);
INT GetCommandFile(
  UINT nClientId,  
  CString& strFileName  
);

Get the full path to the local file name or directory specified by the client

Parameters

nClientId
An unsigned integer which uniquely identifies the client session.
lpszFileName
A pointer to a string buffer that will contain the full path to a file name or directory specified by the client when it issued a command. The string buffer will be null terminated and must be large enough to store the complete file path. This parameter cannot be NULL. An alternate version of this method accepts a CString object if it is available.
nMaxLength
An integer value that specifies the maximum number of characters that can be copied into the string buffer. It is recommended that the buffer be at least MAX_PATH characters in size. If the maximum length specified is smaller than the actual length of the full path, this method will fail.

Return Value

An integer value which specifies the number of characters copied into the buffer, not including the terminating null character. If the method fails, the return value will be zero and the GetLastError method can be used to retrieve the last error code. If the last error code is returned as a value of zero, this means that the command issued by the client accepts a file name as an argument, but the client did not specify one.

Remarks

The GetCommandFile method is used to obtain the full path to a local file name or directory specified by the client as an argument to a standard FTP command. For example, if the client sends the RETR command to the server, this method will return the complete path to the local file that the client wants to download. This method will only work with those standard commands that perform some action on a file or directory.

This method should always be used to obtain the file name for a command that performs a file or directory operation. The GetCommandParam method will return the actual command parameter, but the file name will typically be relative to the user home directory or server root directory, and cannot be passed directly to a Windows API function. The GetCommandFile method normalizes the path provided by the client and ensures that it specifies a file or directory name in the correct location.

To change the file or directory name that is the target of the current command, use the SetCommandFile method.

Requirements

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

See Also

GetClientDirectory, GetClientHomeDirectory, GetCommandLine, GetCommandParam, SetCommandFile