The file type should be set before a file is opened or created on
the server. Once the file type is set, it is in effect for all
files that are subsequently opened or created. Some methods, such as
OpenDirectory, will temporarily change the default file type
to ftpFileTypeText and then restore the current file type
when they return.
Changing the value of this property has no practical effect when
connected to an SFTP (SSH) server. They do not differentiate between
text and binary files and the default file type will always be
ftpFileTypeBinary. If your application is uploading or
downloading a text file, this difference between FTP and SFTP is
important because the operating system that hosts the server may
have different end-of-line character conventions than the client system.
For example, if you download a text file from a UNIX system using
SFTP, the end-of-line is indicated by a single linefeed (LF) character
However, on the Windows platform, the end-of-line is indicated by
a carriage-return and linefeed sequence (CRLF).
If you are transferring binary data, you should always
use ftpFileTypeImage and store the data in a Byte array using
either the GetData or PutData methods. This will ensure
that the data is sent or received exactly as-is without any character
set or end-of-line conversion.
If you need to upload or download text stored in String
variable, use the GetText and PutText
methods. They will always set the file type to ftpFileTypeText
and then restore the previous file type when the method returns. The
value of the CodePage property will allow you to control how
the text is converted to Unicode.