GetText Method  
 

Download a text file from the server and store it in string.

Syntax

object.GetText( 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
This parameter is passed by reference and specifies the string buffer which will contain the text returned by the server. This parameter must be a String or Variant type which will reference a string when the method returns. 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 GetText method is used to download the contents of a text file and store it in a String variable. This method should only be used with text files which are known to be textual. For example, it is safe to use this method when downloading an HTML or XML document, but should not be used to download executable or compressed files (such as Microsoft Word documents or Excel spreadsheets) . Always use the GetData method if you wish to retrieve binary data and store it in a byte array.

The text document returned by the server is automatically converted to Unicode using the code page specified by the CodePage property. Most text files today will use either ASCII or UTF-8 encoding, however some documents may contain text specific to the locale they were created in. Because ASCII is a subset of UTF-8, it is safe to specify UTF-8 encoding for ASCII text documents. If you specify an incorrect code page, this can result in a conversion error.

This method will always attempt to normalize the end-of-line character sequence to use a carriage-return and linefeed (CRLF) pair. 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.

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

See Also

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