SocketTools .NET Edition

FtpClient.PutText Method (String, String, Int32, Int32)

Transfers data from a string buffer and stores it in a file on the remote server.

[Visual Basic]
Overloads Public Function PutText( _
   ByVal remoteFile As String, _
   ByVal buffer As String, _
   ByVal length As Integer, _
   ByVal codePage As Integer _
) As Boolean
[C#]
public bool PutText(
   string remoteFile,
   string buffer,
   int length,
   int codePage
);

Parameters

remoteFile
A string that specifies the file on the remote system that will contain the data being transferred. If the file already exists, it will be overwritten. The file pathing and name conventions must be that of the remote host. The file name can be a complete URL.
buffer
A string which contains the data to be written to the file. If this parameter is null or an empty string, a zero-length file will be created or overwritten on the server.
length
An integer value which specifies the maximum number of characters of data to write. This value cannot be larger than the length of the string buffer.
codePage
An integer value which specifies the code page which should be used to convert the text to Unicode. If this value is zero, the active code page for the current locale will be used. An exception will be thrown if an invalid code page is specified.

Return Value

This method returns a boolean value. If the method succeeds, the return value is true. If the method fails, the return value is false. To get extended error information, check the value of the LastError property.

Remarks

The PutText method uploads data from a string buffer and stores it on a file on the server. This method will cause the current thread to block until the data transfer completes, a timeout occurs or the transfer is canceled.

This method will always set the file transfer mode to text and should only be used to upload readable text to the server. Because the text will be converted from Unicode using the encoding method specified by the codePage parameter, the actual number of bytes stored in the file may differ from the length specified.

See Also