PutText Method  
 

Upload the contents of a string buffer and store it in a text file on the server.

Syntax

object.PutText( RemoteFile, Buffer )

Parameters

RemoteFile
A string that specifies the name of a file on the server that will be downloaded. The file pathing and name conventions must be that of the server.
Buffer
A string which contains the text to be stored on the server. This method will not accept a Byte array as an argument.

Return Value

A value of zero is returned if the operation was successful, otherwise a non-zero error code is returned which indicates the cause of the failure.

Remarks

The PutText method is used to upload the contents of a string and store it as a text file on the server. Although a String variable may contain binary data, this method should only be used with strings which contain printable text. Always use the PutData method if you wish to upload binary data, using a Byte array instead of a String variable.

The text uploaded to the server is automatically converted from Unicode using the code page specified by the CodePage property. By default, text will be automatically converted to use UTF-8 encoding, however you can change this if you prefer to store the file using a different localized encoding. In most cases it is recommended you use UTF-8 to ensure the broadest compatibility with other applications.

This method will always attempt to normalize the end-of-line character sequence to match what is used on the server. This can potentially result in a discrepancy between the size of a text file on the server and the actual length of the string buffer. For example, Windows uses a carriage return and linefeed pair (CRLF) to indicate the end of a line of text. If you are storing the text in a file on a UNIX system, it will be changed to use only a linefeed (LF) to indicate the end of a line.

This method will always use an ASCII file transfer mode, regardless of the value of the FileType property. If the string buffer contains binary data, the resulting file may be empty or contain unprintable characters as the result of the Unicode text conversion.

See Also

CodePage Property, FileType Property, GetData Method, GetText Method, PutData Method, OnProgress Event