FileType Property  
 

Gets and sets the current file transfer type.

Syntax

object.FileType [= filetype ]

Remarks

The FileType property specifies the type of file transfer between the local and server. The file transfer types supported are:

Value Description
ftpFileTypeAuto The file type should be automatically determined based on the file name extension. If the file extension is unknown, the file type should be determined based on the contents of the file. The control has an internal list of common text file extensions, and additional file extensions can be registered using the AddFileType method.
ftpFileTypeASCII The file is a text file using the ASCII character set. For those servers which mark the end of a line with characters other than a carriage return and linefeed, it will be converted to the native client format. This is the file type used for directory listings. The constant ftpFileTypeText is an alias for this value.
ftpFileTypeEBCDIC The file is a text file using the EBCDIC character set. Local files will be converted to EBCDIC when sent to the server. Remote files will be converted to the native ASCII character set when retrieved from the server. Not all servers support this file type. It is recommended that you only specify this type if you know that it is required by the server to transfer data correctly.
ftpFileTypeImage The file is a binary file and no data conversion of any type is performed on the file. This is the default file type for most data files and executable programs. If the type of file cannot be automatically determined, it will always be considered a binary file. If this file type is specified when uploading or downloading text files, the native end-of-line character sequences will be preserved. The constant ftpFileTypeBinary is an alias for this value.
ftpFileTypeLocal The file is a binary file that uses the local byte size for the server platform. On most servers, this file type is considered to be the same as ftpFileTypeBinary. Not all servers support this file type. It is recommended that you only specify this type if you know it is required by the server to transfer data correctly.

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.

Data Type

Integer (Int32)

See Also

CodePage Property, AddFileType Method, GetData Method, GetFile Method, GetText Method, PutData Method, PutFile Method, PutText Method