This method should only be used when the application needs to send
a custom, site-specific command or send a command that is not
directly supported by this class. This method should never be used to
issue a command that opens a data channel. If the application needs
to transform data as it is being sent or received, and cannot use the
GetFile or PutFile methods, then use the
OpenFile method to open a data channel with the server.
By default, file names which are sent to the server using the
Command method are sent as ANSI characters. If the Unicode
version of the function is used, the file name will be converted from
Unicode to ANSI using the current codepage. If the server supports
UTF-8 encoded file names, the SetFileNameEncoding function can
be used to specify that file names with non-ASCII characters should
be sent as UTF-8 encoded values. It is important to note that this
option is only available if the server advertises support for UTF-8
and permits that encoding type.
Because the Command method communicates directly with
the server using the control connection, the idle timeout period
configured with SetIdleTimeout applies to this method
as well. If a session remains inactive for longer than the configured
timeout, the server may close the connection before the command
is sent or before a response is received. Adjusting the idle timeout
can help prevent unexpected disconnects during periods of infrequent
command activity, especially in interactive or long-running operations.
This method is not supported when using SFTP because that
protocol does not provide a mechanism for sending arbitrary command
strings. Unlike the FTP protocol, which uses a command-response model
over a control channel, SFTP uses a structured binary protocol
without support for custom commands. If this method is called
while connected to an SFTP server, it will fail and return an error.