|
INT SetFileType( |
|
UINT nFileType |
|
); |
The SetFileType method sets the default file type for the
current client session, which indicates what type of file is being
opened or created on the server.
Parameters
- hClient
- Handle to the client session.
- nFileType
- Specifies the default type of file being opened or created on
the server. This parameter can be one of the following
values.
Value |
Description |
FILE_TYPE_AUTO |
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 library has an internal list of common text file
extensions, and additional file extensions can be registered
using the FtpRegisterFileType function. |
FILE_TYPE_ASCII |
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. |
FILE_TYPE_EBCDIC |
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. |
FILE_TYPE_IMAGE |
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. |
FILE_TYPE_LOCAL |
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 FILE_TYPE_IMAGE. 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. |
Return Value
If the function succeeds, the return value is the server result
code. If the function fails, the return value is FTP_ERROR. To get
extended error information, call GetLastError.
Remarks
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 and GetText, will temporarily change
the default file type to FILE_TYPE_ASCII and then restore the current
file type when they return.
Calling this method 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 FILE_TYPE_IMAGE. 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).
The GetFileType method can be used to determine the
current file type. To determine the transfer file type for a specific
file, use the GetAutoFileType method.
Requirements
Minimum Desktop Platform: Windows 7 Service Pack 1
Minimum Server Platform: Windows Server 2008 R2 Service Pack 1
Header File: cstools11.h
Import Library: csftpv11.lib
See Also
GetAutoFileType,
GetFileType,
OpenFile,
RegisterFileType,
SetFileMode,
SetFileStructure,
SetPassiveMode
|
|