CFtpClient::PutText Method  
 
INT PutText(
  LPCTSTR lpszRemoteFile,  
  LPCTSTR lpszBuffer  
);

The PutText method creates a text file on the server using the contents of a string buffer.

Parameters

lpszRemoteFile
A null-terminated string that specifies the text file on the server that will be created or overwritten. The file pathing and name conventions must be that of the server.
lpszBuffer
A null-terminated string that contains the text that will be stored in the file.

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

The PutText method is used to create a text file on the server from the contents of a string. If the specified file already exists on the server, its contents will be overwritten. This method will always set the file type to FILE_TYPE_ASCII before creating the file, and will restore the default file type before the method returns.

If the Unicode version of this method is called, the string will be converted to UTF-8 and then uploaded to the server. If you wish to store the contents of the string as UTF-16 Unicode on the server, you must set the current file type to FILE_TYPE_IMAGE and use the PutData method. This method should never be used to upload binary data.

This method will cause the current thread to block until the file transfer completes, a timeout occurs or the transfer is canceled. During the transfer, the FTP_EVENT_PROGRESS event will be periodically fired, enabling the application to update any user interface controls. Event notification must be enabled, either by calling EnableEvents, or by registering a callback function using the RegisterEvent method.

To determine the current status of a file transfer while it is in progress, use the GetTransferStatus method.

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: csftpv12.lib
Unicode: Implemented as Unicode and ANSI versions

See Also