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

Return the original name of a file being renamed by the client.

Parameters

nClientId
An unsigned integer which uniquely identifies the client session.
lpszFileName
A null-terminated string buffer that will contain the full path of the last file or directory that was renamed. It is recommended that this buffer be at least MAX_PATH characters in size. The value of 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, including the terminating null characters. This parameter must have a value larger than zero.

Return Value

If the method succeeds, the return value is the length of the file or directory path, not including the terminating null character. If the client ID does not specify a valid client session, the method will return zero. If the client has not renamed a file or directory, this method will return zero.

Remarks

When a client wishes to rename a file or directory, it must send two commands in sequence to the server. The first command is RNFR (rename from) which specifies the original name of the file or directory to be renamed. The second command is RNTO (rename to) and must be sent immediately after the RNFR command and specifies the new name for the file or directory. The GetRenamedFile method will return the full path of the local file or directory that was specified by the RNFR command. Typically this method is used by an event handler that processes the OnCommand event to determine the original path name.

This method is only guaranteed to return a meaningful value when called within the context of the OnCommand event handler. Calling this method outside of the event handler will return the path of the last renamed file, but there is no way to determine at what point the client issued the command to rename a file or directory. To obtain the new file or directory name, the GetCommandFile method should be called from within the event handler.

The RNFR and RNTO commands can also be used to move a file or directory to a new location. For example, they could be used to move a file from one directory to another. An application should never make the assumption that the paths of the original and new file will be the same.

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