Commercial File Transfer Protocol (FTP) Component.
The proxy scheme used by your FTP proxy server. Valid values are 0 to 6. The default value is 0 which indicates that no proxy server is used. Supported proxy methods are as follows:
Note: The ProxyHostname is the hostname of the firewall, if the proxy is a firewall. Also, the ProxyUsername and ProxyPassword are the firewall username/password (if the proxy is a firewall).
ProxyMethod = 1 (SITE site)
USER ProxyUsername
PASS ProxyPassword
SITE Hostname
USER Username
PASS Password
ProxyMethod = 2 (USER user@site)
USER Username@Hostname:Port
PASS Password
ProxyMethod = 3 (USER with login)
USER ProxyUsername
PASS ProxyPassword
USER Username@Hostname:Port
PASS Password
ProxyMethod = 4 (USER/PASS/ACCT)
USER Username@Hostname:Port ProxyUsername
PASS Password
ACCT ProxyPassword
ProxyMethod = 5 (OPEN site)
USER ProxyUsername
PASS ProxyPassword
OPEN Hostname
USER Username
PASS Password
ProxyMethod = 6 (firewallId@site)
USER ProxyUsername@Hostname
USER Username
PASS Password
ProxyMethod = 7
USER ProxyUsername
USER ProxyPassword
SITE Hostname:Port
USER Username
PASS Password
ProxyMethod = 8
USER Username@ProxyUsername@Hostname
PASS Password@ProxyPassword
void get_ProxyPassword(CkString &str);
void put_ProxyPassword(const char *newVal);
The password for authenticating with the FTP proxy server.
long get_ProxyPort(void);
void put_ProxyPort(long newVal);
If an FTP proxy server is used, this is the port number at which the proxy server is listening for connections.
void get_ProxyUsername(CkString &str);
void put_ProxyUsername(const char *newVal);
The username for authenticating with the FTP proxy server.
long get_ReadTimeout(void);
void put_ReadTimeout(long numSeconds);
Forces a timeout when incoming data is expected on a data channel, but no data arrives for this number of seconds.
The ReadTimeout is the amount of time that needs to elapse while no additional data is forthcoming. During a long download, if the data stream halts for more than this amount, it will timeout. Otherwise, there is no limit on the length of time for the entire download.
The default value is 60.
bool get_RequireSslCertVerify(void);
void put_RequireSslCertVerify(bool newVal);
If true, then the FTP2 client will verify the server's SSL certificate. The certificate is expired, or if the cert's signature is invalid, the connection is not allowed. The default value of this property is false.
bool get_RestartNext(void);
void put_RestartNext(bool newVal);
Both uploads and downloads may be resumed by simply setting this property = true and re-calling the upload or download method.
Example: Restart/Resume FTP Download
Example: Restart/Resume FTP Upload
int get_SendBufferSize(void);
void put_SendBufferSize(int newVal);
The buffer size to be used with the underlying TCP/IP socket for sending. The default value is 65536 (64K). Set it to a smaller value for more frequent percentage completion event callbacks. A larger SendBufferSize may improve performance, but at the expense not having as frequent progress monitoring callbacks (if used and if supported by your programming language).
void get_SessionLog(CkString &str);
Contains the session log if KeepSessionLog is turned on.
void get_SocksHostname(CkString &str);
void put_SocksHostname(const char *newVal);
The SOCKS4/SOCKS5 hostname or IPv4 address (in dotted decimal notation). This property is only used if the SocksVersion property is set to 4 or 5).
void get_SocksPassword(CkString &str);
void put_SocksPassword(const char *newVal);
The SOCKS5 password (if required). The SOCKS4 protocol does not include the use of a password, so this does not apply to SOCKS4.
int get_SocksPort(void);
void put_SocksPort(int newVal);
The SOCKS4/SOCKS5 proxy port. The default value is 1080.
This property only applies if a SOCKS proxy is used (if the SocksVersion property is set to 4 or 5).
void get_SocksUsername(CkString &str);
void put_SocksUsername(const char *newVal);
The SOCKS4/SOCKS5 proxy username. This property is only used if the SocksVersion property is set to 4 or 5).
int get_SocksVersion(void);
void put_SocksVersion(int newVal);
SocksVersion
May be set to one of the following integer values:
0 - No SOCKS proxy is used. This is the default.
4 - Connect via a SOCKS4 proxy.
5 - Connect via a SOCKS5 proxy.
bool get_Ssl(void);
void put_Ssl(bool newVal);
Use TLS/SSL for FTP connections. You would typically set Ssl = true when connecting to port 990 on FTP servers that support TLS/SSL mode. Note: It is more common to use AuthTls.
void get_SslProtocol(CkString &str);
void put_SslProtocol(const char *newVal);
Selects the secure protocol to be used for secure (SSL/TLS) implicit and explicit (AUTH TLS / AUTH SSL) connections . Possible values are:
default
TLS 1.0
SSL 3.0
The default value is "default", which means the client/server negotiate the protocol.
bool get_SslServerCertVerified(void);
Read-only property that returns true if the FTP server's digital certificate was verified when connecting via SSL / TLS.
void get_SyncPreview(CkString &str);
Contains the list of files that would be transferred in a call to SyncRemoteTree2 when the previewOnly argument is set to true. This string property contains one filepath per line, separated by CRLF line endings. After SyncRemoteTree2 is called, this property contains the filepaths of the local files that would be uploaded to the FTP server.
long get_UploadRate(void);
The average upload rate in bytes/second. This property is updated in real-time during any FTP upload (asynchronous or synchronous).
bool get_UseEpsv(void);
void put_UseEpsv(bool newVal);
If true, the FTP2 component will use the EPSV command instead of PASV for passive mode data transfers. The default value of this property is false. (It is somewhat uncommon for FTP servers to support EPSV.)
void get_Username(CkString &str);
void put_Username(const char *newVal);
Username for logging into the FTP server. Defaults to "anonymous".
bool get_Utf8(void) const;
void put_Utf8(bool b);
When set to true, all "const char *" arguments are expected to be utf-8 strings. If set to false, the "const char *" arguments are expected to be ANSI strings.
bool get_VerboseLogging(void);
void put_VerboseLogging(bool newVal);
If set to true, then the LastErrorText may contain more verbose logging.
void get_Version(CkString &str);
Version of the component, such as "1.0.0"
Methods
bool AppendFile(const char * localFilePath, const char * remoteFilePath);
Same as PutFile but the file on the FTP server is appended.
If the remoteFilePath contains non-English characters, it may be necessary to set the DirListingCharset property equal to "utf-8". Please refer to the documentation for the DirListingCharset property.
Returns true for success, false for failure.
bool AppendFileFromBinaryData(const char * remoteFilename, const CkByteData & binaryData);
Same as PutFileFromBinaryData, except the file on the FTP server is appended.
Returns true for success, false for failure.
bool AppendFileFromTextData(const char * remoteFilename, const char * textData);
Same as PutFileFromTextData, except the file on the FTP server is appended.
Returns true for success, false for failure.
void AsyncAbort();
Causes an asynchronous Get or Put to abort.
bool AsyncAppendFileStart(const char * localFilename, const char * remoteFilename);
Initiates an asynchronous append. The file is uploaded and appended to an existing file on the FTP server. The append happens in a background thread and can be aborted by calling AsyncAbort. The AsyncFinished property can be checked periodically to determine when the background transfer is finished. The status of the transfer is available in the AsyncSuccess property. The last-error information is available in the AsyncLog property. The AsyncBytesSent property is updated in real time to reflect the current number of bytes sent while the transfer is in progress. The UploadRate is also updated with the current upload rate in bytes/second. While a transfer is in progress, a program may periodically read the UploadRate and AsyncBytesSent properties to display progress.
Returns true for success, false for failure.
bool AsyncGetFileStart(const char * remoteFilename, const char * localFilename);
Initiates an asynchronous file download. The download happens in a background thread and can be aborted by calling AsyncAbort. The AsyncFinished property can be checked periodically to determine when the background transfer is finished. The status of the transfer is available in the AsyncSuccess property. The last-error information is available in the AsyncLog property. The AsyncBytesReceived property is updated in real time to reflect the current number of bytes received while the transfer is in progress. The DownloadRate is also updated with the current download rate in bytes/second. While a transfer is in progress, a program may periodically read the DownloadRate and AsyncBytesReceived properties to display progress.
Returns true for success, false for failure.
bool AsyncPutFileStart(const char * localFilename, const char * remoteFilename);
Initiates an asynchronous file upload. The file is uploaded and creates a new file on the FTP server, or overwrites an existing file. The upload happens in a background thread and can be aborted by calling AsyncAbort. The AsyncFinished property can be checked periodically to determine when the background transfer is finished. The status of the transfer is available in the AsyncSuccess property. The last-error information is available in the AsyncLog property. The AsyncBytesSent property is updated in real time to reflect the current number of bytes sent while the transfer is in progress. The UploadRate is also updated with the current upload rate in bytes/second. While a transfer is in progress, a program may periodically read the UploadRate and AsyncBytesSent properties to display progress.
Returns true for success, false for failure.
bool ChangeRemoteDir(const char * remoteDirPath);
Changes the current remote directory. The remoteDirPath should be relative to the current remote directory, which is initially the HOME directory of the FTP user account.
If the remoteDirPath contains non-English characters, it may be necessary to set the DirListingCharset property equal to "utf-8". Please refer to the documentation for the DirListingCharset property.
Returns true for success, false for failure.
bool ClearControlChannel();
Reverts the FTP control channel from SSL/TLS to an unencrypted channel. This may be required when using FTPS with AUTH TLS where the FTP client is behind a DSL or cable-modem router that performs NAT (network address translation). If the control channel is encrypted, the router is unable to translate the IP address sent in the PORT command for data transfers. By clearing the control channel, the data transfers will remain encrypted, but the FTP commands are passed unencrypted. Your program would typically clear the control channel after authenticating.
Returns true for success, false for failure.
void ClearDirCache();
TheNumFilesAndDirs property returns the count of files and sub-directories in the current remote FTP directory, according to the ListPattern property. For example, if ListPattern is set to “*.xml”, then NumFilesAndDirs returns the count of XML files in the remote directory.
The 1st time it is accessed, the component will (behind the scenes) fetch the directory listing from the FTP server. This information is cached in the component until (1) the current remote directory is changed, or (2) the ListPattern is changed, or (3) the this method (ClearDirCache) is called.
void ClearSessionLog();
Clears the in-memory session log.
bool Connect();
Connects and logs in to the FTP server using the username/password provided in the component properties. Check the integer value of the ConnectFailReason if this method returns false (indicating failure).
Returns true for success, false for failure.
bool ConvertToTls();
Explicitly converts the control channel to a secure SSL/TLS connection.
Note: If you initially connect with either the AuthTls or AuthSsl property set to true, then DO NOT call ConvertToTls. The control channel is automatically converted to SSL/TLS from within the Connect method when these properties are set.
Note: It is very uncommon for this method to be needed.
bool CreatePlan(const char * localDir, CkString & outStr);
Creates an "FTP plan" that lists the FTP operations that would be performed when PutTree is called. Additionally, the PutPlan method executes an "FTP plan" and logs each successful operation to a plan log file. If a large-scale upload is interrupted, the PutPlan can be resumed, skipping over the operations already listed in the plan log file.
Returns true for success, false for failure.
bool CreateRemoteDir(const char * remoteDirPath);
Creates a directory on the FTP server. If the directory already exists, a new one is not created and false is returned.
If the remoteDirPath contains non-English characters, it may be necessary to set the DirListingCharset property equal to "utf-8". Please refer to the documentation for the DirListingCharset property.
Returns true for success, false for failure.
long DeleteMatching(const char * remotePattern);
Deletes all the files in the current remote FTP directory matching the pattern. Returns the number of files deleted, or -1 for failure. The pattern is a string such as "*.txt", where any number of "*" wildcard characters can be used. "*" matches 0 or more of any character.
bool DeleteRemoteFile(const char * remoteFilePath);
Deletes a file on the FTP server.
If the remoteFilePath contains non-English characters, it may be necessary to set the DirListingCharset property equal to "utf-8". Please refer to the documentation for the DirListingCharset property.
Returns true for success, false for failure.
bool DeleteTree();
Deletes the entire subtree and all files from the current remote FTP directory. To delete a subtree on the FTP server, your program would first navigate to the root of the subtree to be deleted by calling ChangeRemoteDir, and then call DeleteTree. There are two event callbacks: VerifyDeleteFile and VerifyDeleteDir. Both are called prior to deleting each file or directory. The arguments to the callback include the full filepath of the file or directory, and an output-only "skip" flag. If your application sets the skip flag to true, the file or directory is NOT deleted. If a directory is not deleted, all files and sub-directories will remain. Example programs can be found at http://www.example-code.com/
Returns true for success, false for failure.
Delete FTP Directory Tree
int DetermineProxyMethod();
Automatically determines the ProxyMethod that should be used with an FTP proxy server. Tries each of the five possible ProxyMethod settings and returns the value (1-5) of the ProxyMethod that succeeded.
This method may take a minute or two to complete. Returns 0 if no proxy methods were successful. Returns -1 to indicate an error (i.e. it was unable to test all proxy methods.)
Automatically Determine FTP Proxy Method
bool DetermineSettings(CkString & outXmlReport);
Discovers which combinations of FTP2 property settings result in successful data transfers.
DetermineSettings tries 13 different combinations of these properties:
Ssl
AuthTls
AuthSsl
Port
Passive
PassiveUseHostAddr
Within the FTP protocol, the process of fetching a directory listing is also considered a “data transfer”. The DetermineSettings method works by checking to see which combinations result in a successful directory listing download. The method takes no arguments and returns a string containing an XML report of the results. It is a blocking call that may take approximately a minute to run. If you are unsure about how to interpret the results, cut-and-paste it into an email and send it to support@chilkatsoft.com.Returns true for success, false for failure.
DetermineSettings Example
bool DirTreeXml(CkString & outStrXml);
Recursively downloads the structure of a complete remote directory tree. Returns an XML document with the directory structure. A zero-length string is returned to indicate failure.
Returns true for success, false for failure.
Download Directory Tree Listing as XML
bool Disconnect();
Disconnects from the FTP server, ending the current session.
Returns true for success, false for failure.
bool DownloadTree(const char * localRoot);
Downloads an entire tree from the FTP server and recreates the directory tree on the local filesystem.
This method downloads all the files and subdirectories in the current remote directory. An application would first navigate to the directory to be downloaded via ChangeRemoteDir and then call this method.
There are three event callbacks (for programming languages supporting events): BeginDownloadFile, EndDownloadFile, and VerifyDownloadDir. The 1st argument to each callback is the fully qualified pathname of the file or directory. The BeginDownloadFile event callbacks has a "skip" argument, which is output-only. The application can set it to true to prevent the file from being downloaded. The VerifyDownloadDir also has a "skip" argument where the application can cause an entire sub-tree to be skipped. The EndDownloadFile event includes a "numBytes" argument containing the size of the file in bytes.
Returns true for success, false for failure.
Download Directory Tree Listing as XML
bool Feat(CkString & outStr);
Sends a FEAT command to the FTP server and returns the response. Returns a zero-length string to indicate failure. Here is a typical response:
211-Features:
MDTM
REST STREAM
SIZE
MLST type*;size*;modify*;
MLSD
AUTH SSL
AUTH TLS
UTF8
CLNT
MFMT
211 End
Returns true for success, false for failure.
FTP FEAT Command
bool GetCreateTime(long index, FILETIME & outFileTime);
Returns the create time for the Nth file or sub-directory in the current remote directory. The first file/dir is at index 0, and the last one is at index (NumFilesAndDirs-1)
bool GetCreateTime(long index, SYSTEMTIME & outSysTime);
Returns the create time for the Nth file or sub-directory in the current remote directory. The first file/dir is at index 0, and the last one is at index (NumFilesAndDirs-1)
bool GetCreateTimeByName(const char * filename, SYSTEMTIME & outSysTime);
Returns the file-creation time for a remote file by filename.
bool GetCurrentRemoteDir(CkString & outStr);
Returns the current remote directory.
Returns true for success, false for failure.
bool GetFile(const char * remoteFilePath, const char * localFilePath);
Downloads a file from the FTP server to the local filesystem.
If the remoteFilePath contains non-English characters, it may be necessary to set the DirListingCharset property equal to "utf-8". Please refer to the documentation for the DirListingCharset property.
Returns true for success, false for failure.
bool GetFilename(long index, CkString & outStr);
Returns the filename for the Nth file or sub-directory in the current remote directory. The first file/dir is at index 0, and the last one is at index (NumFilesAndDirs-1)
Returns true for success, false for failure.
bool GetIsDirectory(long index);
Returns true for a sub-directory and false for a file, for the Nth entry in the current remote directory. The first file/dir is at index 0, and the last one is at index (NumFilesAndDirs-1)
bool GetIsSymbolicLink(long index);
Returns true if the remote file is a symbolic link. (Symbolic links only exist on Unix/Linux systems, not on Windows filesystems.)
bool GetLastAccessTime(long index, FILETIME & outFileTime);
Returns the last access time for the Nth file or sub-directory in the current remote directory. The first file/dir is at index 0, and the last one is at index (NumFilesAndDirs-1)
bool GetLastAccessTime(long index, SYSTEMTIME & outSysTime);
Returns the last access time for the Nth file or sub-directory in the current remote directory. The first file/dir is at index 0, and the last one is at index (NumFilesAndDirs-1)
bool GetLastAccessTimeByName(const char * filename, SYSTEMTIME & outSysTime);
Returns a remote file's last-access time.
bool GetLastModifiedTime(long index, FILETIME & outFileTime);
Returns the last modified time for the Nth file or sub-directory in the current remote directory. The first file/dir is at index 0, and the last one is at index (NumFilesAndDirs-1)
bool GetLastModifiedTime(long index, SYSTEMTIME & outSysTime);
Returns the last modified time for the Nth file or sub-directory in the current remote directory. The first file/dir is at index 0, and the last one is at index (NumFilesAndDirs-1)
bool GetLastModifiedTimeByName(const char * filename, SYSTEMTIME & outSysTime);
Returns the last-modified date/time for a remote file.
bool GetRemoteFileBinaryData(const char * remoteFilename, CkByteData & outData);
Downloads the contents of a remote file into a byte array.
Returns false on failure.
bool GetRemoteFileTextC(const char * remoteFilename, const char * charset, CkString & outStr);
Downloads a text file directly into a string variable. The character encoding of the text file is specified by the charset argument, which is a value such as utf-8, iso-8859-1, Shift_JIS, etc.
Returns true for success, false for failure.
bool GetRemoteFileTextData(const char * remoteFilename, CkString & outStr);
Downloads the content of a remote text file directly into an in-memory string.
Note: If the remote text file does not use the ANSI character encoding, call GetRemoteFileTextC instead, which allows for the character encoding to be specified so that characters are properly interpreted.
Returns true for success, false for failure.
long GetSize(long index);
Returns the size of the Nth remote file in the current directory.
__int64 GetSize64(int index);
Returns the size of the Nth remote file in the current directory as a 64-bit integer.
long GetSizeByName(const char * filname);
Returns a remote file's size in bytes.
__int64 GetSizeByName64(const char * filename);
Returns a remote file's size in bytes as a 64-bit integer.
bool GetSizeStr(long index, CkString & outStr);
Returns the size in decimal string format of the Nth remote file in the current directory. This is helpful for cases when the file size (in bytes) is greater than what can fit in a 32-bit integer.
Returns true for success, false for failure.
bool GetSizeStrByName(const char * filename, CkString & outStr);
Returns the size of a remote file as a string. This is helpful when file a file size is greater than what can fit in a 32-bit integer.
Returns true for success, false for failure.
CkCert * GetSslServerCert();
Returns the FTP server's digital certificate (for SSL / TLS connections).
bool GetTextDirListing(const char * pattern, CkString & outStrRawListing);
Returns a listing of the files and directories in the current directory matching the pattern. Passing "*.*" will return all the files and directories.
Returns true for success, false for failure.
bool GetXmlDirListing(const char * pattern, CkString & outStrXmlListing);
Returns (in XML format) the files and directories in the current directory matching the pattern. Passing "*.*" will return all the files and directories.
Returns true for success, false for failure.
bool IsUnlocked();
Return true if the component is already unlocked.
long MGetFiles(const char * remotePattern, const char * localDir);
Copies all the files in the current remote FTP directory to a local directory. To copy all the files in a remote directory, set remotePattern to "*.*" The pattern can contain any number of "*"characters, where "*" matches 0 or more of any character. The return value is the number of files transferred, and on error, a value of -1 is returned. Detailed information about the transfer can be obtained from the last-error information (LastErrorText/LastErrorHtml/LastErrorXml/SaveLastError).
About case sensitivity: The MGetFiles command works by sending the "LIST" command to the FTP server. For example: "LIST *.txt". The FTP server responds with a directory listing of the files matching the wildcarded pattern, and it is these files that are downloaded. Case sensitivity depends on the case-sensitivity of the remote file system. If the FTP server is running on a Windows-based computer, it is likely to be case insensitive. However, if the FTP server is running on Linux, MAC OS X, etc. it is likely to be case sensitive. There is no good way to force case-insensitivity if the remote filesystem is case-sensitive because it is not possible for the FTP client to send a LIST command indicating that it wants the matching to be case-insensitive.
long MPutFiles(const char * pattern);
Uploads all the files matching pattern on the local computer to the current remote FTP directory. The pattern parameter can include directory information, such as "C:/my_dir/*.txt" or it can simply be a pattern such as "*.*" that matches the files in the application's current directory. Subdirectories are not recursed. The return value is the number of files copied, with a value of -1 returned for errors. Detailed information about the transfer can be obtained from the XML log.[
bool NlstXml(const char * remoteDirPattern, CkString & outStr);
Sends an NLST command to the FTP server and returns the results in XML format. The NLST command returns a list of filenames in the given directory (matching the pattern). The remoteDirPattern should be a pattern such as "*", "*.*", "*.txt", "subDir/*.xml", etc.
The format of the XML returned is:
<nlst>
<e>filename_or_dir_1</e>
<e>filename_or_dir_2</e>
<e>filename_or_dir_3</e>
<e>filename_or_dir_4</e>
...
</nlst>
Returns true for success, false for failure.
bool Noop();
Issues a no-op command to the FTP server.
bool PutFile(const char * localFilePath, const char * remoteFilePath);
Uploads a local file to the current directory on the FTP server.
If the remoteFilePath contains non-English characters, it may be necessary to set the DirListingCharset property equal to "utf-8". Please refer to the documentation for the DirListingCharset property.
Returns true for success, false for failure.
bool PutFileFromBinaryData(const char * remoteFilename, const CkByteData & binaryData);
Creates a file on the remote server containing the data passed in a byte array.
Returns true for success, false for failure.
bool PutFileFromTextData(const char * remoteFilename, const char * textData);
Creates a file on the remote server containing the data passed in a string.
Returns true for success, false for failure.
bool PutPlan(const char * planUtf8, const char * planLogFilename);
Executes an "FTP plan" (created by the CreatePlan method) and logs each successful operation to a plan log file. If a large-scale upload is interrupted, the PutPlan can be resumed, skipping over the operations already listed in the plan log file. When resuming an interrupted PutPlan method, use the same log file. All completed operations found
in the already-existing log will automatically be skipped.
Returns true for success, false for failure.
bool PutTree(const char * localDir);
Uploads an entire directory tree from the local filesystem to the remote FTP server, recreating the directory tree on the server. The PutTree method copies a directory tree to the current remote directory on the FTP server.
Returns true for success, false for failure.
bool Quote(const char * cmd);
Sends an arbitrary (raw) command to the FTP server.
Returns true for success, false for failure.
Quote Example
bool RemoveRemoteDir(const char * remoteDirPath);
Removes a directory from the FTP server.
If the remoteDirPath contains non-English characters, it may be necessary to set the DirListingCharset property equal to "utf-8". Please refer to the documentation for the DirListingCharset property.
bool RenameRemoteFile(const char * existingRemoteFilePath, const char * newRemoteFilePath);
Renames a file or directory on the FTP server. To move a file from one directory to another on a remote FTP server, call this method and include the source and destination directory filepath.
If the existingRemoteFilePath or newRemoteFilePath contains non-English characters, it may be necessary to set the DirListingCharset property equal to "utf-8". Please refer to the documentation for the DirListingCharset property.
bool SaveLastError(const char * filename);
Saves the last error information to an XML formatted file.
bool SendCommand(const char * cmd, CkString & outReply);
Sends an raw command to the FTP server and returns the raw response.
Returns true for success, false for failure.
SendCommand Example
bool SetModeZ();
Chilkat FTP2 supports MODE Z, which is a transfer mode implemented by some FTP servers. It allows for files to be uploaded and downloaded using compressed streams (using the zlib deflate algorithm).
Call this method after connecting to enable Mode Z. Once enabled, all transfers (uploads, downloads, and directory listings) are compressed.
Returns true for success, false for failure.
void SetOldestDate(SYSTEMTIME & oldestDateTime);
Used in conjunction with the DownloadTree method. Call this method prior to calling DownloadTree to set the oldest date for a file to be downloaded. When DownloadTree is called, any file older than this date will not be downloaded.
bool SetRemoteFileDateTime(SYSTEMTIME & dateTime, const char * remoteFilename);
Sets the last-modified date/time of a file on the FTP server. Important: Not all FTP servers support this functionality. Please see the information at the Chilkat blog below:
Setting FTP date/time not supported by all FTP servers.
void SetSslCertRequirement(const char * reqName, const char * reqValue);
Enforces a requirement on the FTP server's certificate. The reqName can be "SubjectDN", "SubjectCN", "IssuerDN", or "IssuerCN". The reqName specifies the part of the certificate, and the reqValue is the value that it must match (exactly). If the FTP server's certificate does not match, the SSL / TLS connection is aborted.
bool SetSslClientCert(CkCert & cert);
Allows for a client-side certificate to be used for the SSL / TLS connection.
Returns true for success, false for failure.
bool SetSslClientCertPem(const char * pemDataOrFilename, const char * pemPassword);
Allows for a client-side certificate to be used for the SSL / TLS connection.
Returns true for success, false for failure.
bool SetSslClientCertPfx(const char * pfxFilename, const char * pfxPassword, const char * certSubjectCN);
Allows for a client-side certificate to be used for the SSL / TLS connection.
Returns true for success, false for failure.
bool SetTypeAscii();
Set the FTP transfer mode to us-ascii.
Returns true for success, false for failure.
bool SetTypeBinary();
Set the FTP transfer mode to binary.
Returns true for success, false for failure.
bool Site(const char * params);
Sends an arbitrary "site" command to the FTP server. The params argument should contain the parameters to the site command as they would appear on a command line. For example: "recfm=fb lrecl=600".
Returns true for success, false for failure.
void SleepMs(int millisec);
Causes the calling process to sleep for a number of milliseconds.
bool Stat(CkString & outStr);
Sends a STAT command to the FTP server and returns the server's reply.
Returns true for success, false for failure.
bool SyncLocalTree(const char * localRoot, int mode);
Downloads files from the FTP server to a local directory tree. Synchronization modes include:
mode=0: Download all files
mode=1: Download all files that do not exist on the local filesystem.
mode=2: Download newer or non-existant files.
mode=3: Download only newer files. If a file does not already exist on the local filesystem, it is not downloaded from the server.
mode=5 - Download only missing files or files with size differences.
mode=6 - Same as mode 5, but also download newer files.
* There is no mode #4. It is a mode used internally by the DirTreeXml method.
Returns true for success, false for failure.
Example: Synchronize Local Directory Tree
bool SyncRemoteTree(const char * localRoot, int mode);
Uploads a directory tree from the local filesystem to the FTP server. Synchronization modes include:
mode=0: Upload all files
mode=1: Upload all files that do not exist on the FTP server.
mode=2: Upload newer or non-existant files.
mode=3: Upload only newer files. If a file does not already exist on the FTP server, it is not uploaded.
mode=4: transfer missing files or files with size differences.
mode=5: same as mode 4, but also newer files.
Returns true for success, false for failure.
Example: Synchronize Remote Directory Tree
bool SyncRemoteTree2(const char * localDirPath, int mode, bool bDescend, bool bPreviewOnly);
Same as SyncRemoteTree, except two extra arguments are added to allow for more flexibility. If bDescend is false, then the directory tree is not descended and only the files in localDirPath are synchronized. If bPreviewOnly is true then no files are transferred and instead the files that would've been transferred (had bPreviewOnly been set to false) are listed in the SyncPreview property.
Returns true for success, false for failure.
bool Syst(CkString & outStr);
Sends a SYST command to the FTP server to find out the type of operating
system at the server. The method returns the FTP server's response string. Refer to RFC 959 for details.
Returns true for success, false for failure.
bool UnlockComponent(const char * code);
Unlocks the component. This must be called once prior to calling any other method. A permanent unlock code for FTP2 should contain the substring "FTP".
Diagnosing UnlockComponent Problems
UnlockComponent LastErrorText shows exact string passed to it.
Verify UnlockComponent Success w/ Permanent Unlock Code
LastErrorText Standard Information
How UnlockComponent Works
const char * account();
Some FTP servers require an Account name in addition to login/password. This property can be set for those servers with this requirement.
Returns a null on failure
const char * asyncLog();
The last-error information for an asynchronous (background) file transfer.
Returns a null on failure
const char * ck_stat();
To be documented soon...
const char * clientIpAddress();
The IP address to use for computers with multiple network interfaces or IP addresses.
For computers with a single network interface (i.e. most computers), this property should not be set. For multihoming computers, the default IP address is automatically used if this property is not set.
The IP address is a string such as in dotted notation using numbers, not domain names, such as "165.164.55.124".
Returns a null on failure
Important Bind to Adapter Notes for Windows
const char * createPlan(const char * localDir);
Creates an "FTP plan" that lists the FTP operations that would be performed when PutTree is called. Additionally, the PutPlan method executes an "FTP plan" and logs each successful operation to a plan log file. If a large-scale upload is interrupted, the PutPlan can be resumed, skipping over the operations already listed in the plan log file.
Returns a null on failure
const char * debugLogFilePath();
Used for debugging in cases where a Chilkat method call hangs and never returns. This should generally never happen. The only causes for this are (1) a timeout related property was set to 0 to explicitly indicate that an infinite timeout is desired, (2) the hang is actually a hang within an event callback (i.e. it is a hang within the application code), or (3) there is an internal problem (bug) in the Chilkat code that causes the hang.
This property allows one to specifiy a debug file path that will be created (or appended if it already exists) and information will be logged to it as the Chilkat methods are called. If a hang occurs, the log file may be viewed to get information about what happened.
Returns a null on failure
const char * determineSettings();
Discovers which combinations of FTP2 property settings result in successful data transfers.
DetermineSettings tries 13 different combinations of these properties:
Ssl
AuthTls
AuthSsl
Port
Passive
PassiveUseHostAddr
Within the FTP protocol, the process of fetching a directory listing is also considered a “data transfer”. The DetermineSettings method works by checking to see which combinations result in a successful directory listing download. The method takes no arguments and returns a string containing an XML report of the results. It is a blocking call that may take approximately a minute to run. If you are unsure about how to interpret the results, cut-and-paste it into an email and send it to support@chilkatsoft.com.Returns a null on failure
DetermineSettings Example
const char * dirListingCharset();
Set to "ansi" by default. If the FTP server sends directory listings with non-English filenames, this property can be set to the appropriate value if necessary.
Note: This property also applies to all FTP operations where a filename or path is sent over the command channel, such as when uploading or downloadiing files. If the remote file path uses non-English characters, such as Chinese, it is likely that this property should be set to "utf-8" so that these characters are sent correctly.
Returns a null on failure
const char * dirTreeXml();
Recursively downloads the structure of a complete remote directory tree. Returns an XML document with the directory structure. A zero-length string is returned to indicate failure.
Returns a null on failure
Download Directory Tree Listing as XML
const char * feat();
Sends a FEAT command to the FTP server and returns the response. Returns a zero-length string to indicate failure. Here is a typical response:
211-Features:
MDTM
REST STREAM
SIZE
MLST type*;size*;modify*;
MLSD
AUTH SSL
AUTH TLS
UTF8
CLNT
MFMT
211 End
Returns a null on failure
FTP FEAT Command
const char * forcePortIpAddress();
If set, forces the IP address used in the PORT command for Active mode (i.e. non-passive) data transfers. This string property should be set to the IP address in dotted notation, such as "233.190.65.31".
Returns a null on failure
const char * getCurrentRemoteDir();
Returns the current remote directory.
Returns a null on failure
const char * getFilename(long index);
Returns the filename for the Nth file or sub-directory in the current remote directory. The first file/dir is at index 0, and the last one is at index (NumFilesAndDirs-1)
Returns a null on failure
const char * getRemoteFileTextC(const char * remoteFilename, const char * charset);
Downloads a text file directly into a string variable. The character encoding of the text file is specified by the charset argument, which is a value such as utf-8, iso-8859-1, Shift_JIS, etc.
Returns a null on failure
const char * getRemoteFileTextData(const char * remoteFilename);
Downloads the content of a remote text file directly into an in-memory string.
Note: If the remote text file does not use the ANSI character encoding, call GetRemoteFileTextC instead, which allows for the character encoding to be specified so that characters are properly interpreted.
Returns a null on failure
const char * getSizeStr(long index);
Returns the size in decimal string format of the Nth remote file in the current directory. This is helpful for cases when the file size (in bytes) is greater than what can fit in a 32-bit integer.
Returns a null on failure
const char * getSizeStrByName(const char * filename);
Returns the size of a remote file as a string. This is helpful when file a file size is greater than what can fit in a 32-bit integer.
Returns a null on failure
const char * getTextDirListing(const char * pattern);
Returns a listing of the files and directories in the current directory matching the pattern. Passing "*.*" will return all the files and directories.
Returns a null on failure
const char * getXmlDirListing(const char * pattern);
Returns (in XML format) the files and directories in the current directory matching the pattern. Passing "*.*" will return all the files and directories.
Returns a null on failure
const char * greeting();
The initial greeting received from the FTP server after connecting.
Returns a null on failure
const char * hostname();
The domain name of the FTP server. May also use the IPv4 or IPv6 address in string format.
Returns a null on failure
const char * httpProxyAuthMethod();
To be documented soon...
const char * httpProxyDomain();
To be documented soon...
const char * httpProxyHostname();
To be documented soon...
const char * httpProxyPassword();
To be documented soon...
const char * httpProxyUsername();
To be documented soon...
const char * lastErrorHtml();
Error information in HTML format for the last method called.Returns a null on failure
const char * lastErrorText();
Error information in plain-text format for the last method called.Returns a null on failure
const char * lastErrorXml();
Error information in XML format for the last method called.Returns a null on failure
const char * listPattern();
A wildcard pattern, defaulting to "*" that determines the files and directories included in the following properties and methods: NumFilesAndDirs, GetCreateTime, GetFilename, GetIsDirectory, GetLastAccessTime, GetModifiedTime, GetSize.
Note: Do not include a directory path in the ListPattern. For example, do not set the ListPattern equal to a string such as this: "subdir/*.txt". The correct solution is to first change the remote directory to "subdir" by calling ChangeRemoteDir, and then set the ListPattern equal to "*.txt".
Returns a null on failure
const char * nlstXml(const char * remoteDirPattern);
Sends an NLST command to the FTP server and returns the results in XML format. The NLST command returns a list of filenames in the given directory (matching the pattern). The remoteDirPattern should be a pattern such as "*", "*.*", "*.txt", "subDir/*.xml", etc.
The format of the XML returned is:
<nlst>
<e>filename_or_dir_1</e>
<e>filename_or_dir_2</e>
<e>filename_or_dir_3</e>
<e>filename_or_dir_4</e>
...
</nlst>
Returns a null on failure
const char * password();
Password for logging into the FTP server.
Returns a null on failure
const char * proxyHostname();
The hostname of your FTP proxy, if a proxy server is used.
Returns a null on failure
const char * proxyPassword();
The password for authenticating with the FTP proxy server.
Returns a null on failure
const char * proxyUsername();
The username for authenticating with the FTP proxy server.
Returns a null on failure
const char * sendCommand(const char * cmd);
Sends an raw command to the FTP server and returns the raw response.
Returns a null on failure
SendCommand Example
const char * sessionLog();
Contains the session log if KeepSessionLog is turned on.
Returns a null on failure
const char * socksHostname();
The SOCKS4/SOCKS5 hostname or IPv4 address (in dotted decimal notation). This property is only used if the SocksVersion property is set to 4 or 5).
Returns a null on failure
const char * socksPassword();
The SOCKS5 password (if required). The SOCKS4 protocol does not include the use of a password, so this does not apply to SOCKS4.
Returns a null on failure
const char * socksUsername();
The SOCKS4/SOCKS5 proxy username. This property is only used if the SocksVersion property is set to 4 or 5).
Returns a null on failure
const char * sslProtocol();
Selects the secure protocol to be used for secure (SSL/TLS) implicit and explicit (AUTH TLS / AUTH SSL) connections . Possible values are:
default
TLS 1.0
SSL 3.0
The default value is "default", which means the client/server negotiate the protocol.Returns a null on failure
const char * syncPreview();
Contains the list of files that would be transferred in a call to SyncRemoteTree2 when the previewOnly argument is set to true. This string property contains one filepath per line, separated by CRLF line endings. After SyncRemoteTree2 is called, this property contains the filepaths of the local files that would be uploaded to the FTP server.
Returns a null on failure
const char * syst();
Sends a SYST command to the FTP server to find out the type of operating
system at the server. The method returns the FTP server's response string. Refer to RFC 959 for details.
Returns a null on failure
const char * username();
Username for logging into the FTP server. Defaults to "anonymous".
Returns a null on failure
const char * version();
Version of the component, such as "1.0.0"
Returns a null on failure