ChilkatFtp2 ActiveX Reference

ChilkatFtp2

Commercial File Transfer Protocol (FTP) Component.

Object Creation

(Visual Basic 6.0)
Dim obj As New ChilkatFtp2
(ASP)
set obj = Server.CreateObject("Chilkat.Ftp2")
(VBScript)
set obj = CreateObject("Chilkat.Ftp2")
(Delphi)
obj := TChilkatFtp2.Create(Self);
(FoxPro)
loObject = CreateObject('Chilkat.Ftp2')
(SQL Server)
EXEC @hr = sp_OACreate 'Chilkat.Ftp2', @obj OUT
(Javascript)
var obj = new ActiveXObject("Chilkat.Ftp2");

Properties

Account As String

Some FTP servers require an Account name in addition to login/password. This property can be set for those servers with this requirement.

ActivePortRangeEnd As Long

When Active (i.e. PORT) mode is used (opposite of Passive), the client-side is responsible for choosing a random port for each data connection. (Note: In the FTP protocol, each data transfer occurs on a separate TCP/IP connection. Commands are sent over the control channel (port 21 for non-SSL, port 990 for SSL).)

This property, along with ActivePortRangeStart, allows the client to specify a range of ports for data connections.

more information about FTP port ranges

ActivePortRangeStart As Long

This property, along with ActivePortRangeEnd, allows the client to specify a range of ports for data connections when in Active mode.

more information about FTP port ranges

AllocateSize As Long

If set to a non-zero value, causes an ALLO command, with this size as the parameter, to be automatically sent when uploading files to an FTP server.

This command could be required by some servers to reserve sufficient storage space to accommodate the new file to be transferred.

AsyncBytesReceived As Long (read-only)

The number of bytes received during an asynchronous FTP download. This property is updated in real-time and an application may periodically fetch and display it's value while the download is in progress.

AsyncBytesReceivedStr As String (read-only)

The number of bytes received during an asynchronous FTP download. This property is updated in real-time and an application may periodically fetch and display it's value while the download is in progress.

AsyncBytesSent As Long (read-only)

The number of bytes sent during an asynchronous FTP upload. This property is updated in real-time and an application may periodically fetch and display it's value while the upload is in progress.

AsyncBytesSentStr As String (read-only)

The number of bytes sent during an asynchronous FTP upload. This string property is updated in real-time and an application may periodically fetch and display it's value while the upload is in progress.

AsyncFinished As Long (read-only)

Set to 1 if the asynchronous transfer (download or upload) is finished.

AsyncLog As String (read-only)

The last-error information for an asynchronous (background) file transfer.

AsyncSuccess As Long (read-only)

Set to 1 if the asynchronous file transfer succeeded.

AuthSsl As Long

Same as AuthTls, except the command sent to the FTP server is "AUTH SSL" instead of "AUTH TLS". Most FTP servers accept either. AuthTls is more commonly used. If a particular server has trouble with AuthTls, try AuthSsl instead.

AuthTls As Long

Set this to 1 to switch to a TLS 1.0 encrypted channel. This property should be set prior to connecting. If this property is set, the port typically remains at it's default (21) and the Ssl property should *not* be set. When AuthTls is used, all control and data transmissions are encrypted. If your FTP client is behind a network-address-translating router, you may need to call ClearControlChannel after connecting and authenticating (i.e. after calling the Connect method). This keeps all data transmissions encrypted, but clears the control channel so that commands are sent unencrypted, thus allowing the router to translate network IP numbers in FTP commands.

AutoFeat As Long

When 1 (which is the default value), a "FEAT" command is automatically sent to the FTP server immediately after connecting. This allows the Chilkat FTP2 component to know more about the server's capabilities and automatically adjust any applicable internal settings based on the response. In rare cases, some FTP servers reject the "FEAT" command and close the connection. Usually, if an FTP server does not implement FEAT, a harmless "command not understood" response is returned.

Set this property to 0 to prevent the FEAT command from being sent.

AutoFix As Long

If 1, then the following will occur when a connection is made to an FTP server:

1) If the Port property = 990, then sets AuthTls = 0, AuthSsl = 0, and Ssl = 1
2) If the Port property = 21, sets Ssl = 0

The default value of this property is 1.

AutoGetSizeForProgress As Long

Forces the component to retrieve each file's size prior to downloading for the purpose of monitoring percentage completion progress. For many FTP servers, this is not required and therefore for performance reasons this property defaults to 0.

AutoSyst As Long

When 1 (which is the default value), a "SYST" command is automatically sent to the FTP server immediately after connecting. This allows the Chilkat FTP2 component to know more about the server and automatically adjust any applicable internal settings based on the response. If the SYST command causes trouble (which is rare), this behavior can be turned off by setting this property equal to 0.

AutoXcrc As Long

Many FTP servers support the XCRC command. The Chilkat FTP component will automatically know if XCRC is supported because it automatically sends a FEAT command to the server immediately after connecting.

If this property is set to 1, then all uploads will be automatically verified by sending an XCRC command immediately after the transfer completes. If the CRC is not verified, the upload method (such as PutFile) will return a failed status.

To prevent XCRC checking, set this property to 0.

BandwidthThrottleDown As Long

If set to a non-zero value, the FTP2 component will bandwidth throttle all downloads to this value.

The default value of this property is 0. The value should be specified in bytes/second.

Note: It is difficult to throttle very small downloads. (For example, how do you bandwidth throttle a 1-byte download???) As the downloaded file size gets larger, the transfer rate will better approximate this property's setting.

(ASP) FTP Bandwidth Throttle for Downloads

(VB6) FTP Bandwidth Throttle for Downloads

(Delphi) FTP Bandwidth Throttle for Downloads

(FoxPro) FTP Bandwidth Throttle for Downloads

(PHP using ActiveX) FTP Bandwidth Throttle for Downloads

(VBScript) FTP Bandwidth Throttle for Downloads

BandwidthThrottleUp As Long

If set to a non-zero value, the FTP2 component will bandwidth throttle all uploads to this value.

The default value of this property is 0. The value should be specified in bytes/second.

Note: It is difficult to throttle very small uploads. (For example, how do you bandwidth throttle a 1-byte upload???) As the uploaded file size gets larger, the transfer rate will better approximate this property's setting.

(ASP) FTP Bandwidth Throttle for Upload

(VB6) FTP Bandwidth Throttle for Upload

(Delphi) FTP Bandwidth Throttle for Upload

(FoxPro) FTP Bandwidth Throttle for Upload

(PHP using ActiveX) FTP Bandwidth Throttle for Upload

(VBScript) FTP Bandwidth Throttle for Upload

ClientIpAddress As String

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".

Important Bind to Adapter Notes for Windows

ConnectFailReason As Long (read-only)

If the Connect method fails, this property can be checked to determine the reason for failure.

Possible values are:

0 = success
Normal (non-SSL) sockets:
1 = empty hostname
2 = DNS lookup failed
3 = DNS timeout
4 = Aborted by application.
5 = Internal failure.
6 = Connect Timed Out
7 = Connect Rejected (or failed for some other reason)
SSL:
100 = Internal schannel error
101 = Failed to create credentials
102 = Failed to send initial message to proxy.
103 = Handshake failed.
104 = Failed to obtain remote certificate.
105 = Failed to verify server certificate.
FTP:
200 = Connected, but failed to receive greeting from FTP server.
201 = Failed to do AUTH TLS or AUTH SSL.
Protocol/Component:
300 = asynch op in progress
301 = login failure.

ConnectTimeout As Long

Maximum number of seconds to wait when connecting to an FTP server.

ConnectVerified As Long (read-only)

True if the FTP2 component was able to establish a TCP/IP connection to the FTP server after calling Connect.

CrlfMode As Long

Used to control CRLF line endings when downloading text files in ASCII mode. The default value is 0.

Possible values are:

0 = Do nothing.  The line-endings are not modified as received from the FTP server.
1 = Convert all line-endings to CR+LF
2 = Convert all line-endings to bare LF's
3 = Convert all line-endings to bare CR's

DebugLogFilePath As String

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.

DirListingCharset As String

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.

DllInfo As String (read-only)

Returns "32-bit" or "64-bit" to indicate whether this DLL is compiled for 32-bit or 64-bit.

DllPath As String (read-only)

The physical filesystem path where the DLL for this ActiveX is located.

DownloadRate As Long (read-only)

The average download rate in bytes/second. This property is updated in real-time during any FTP download (asynchronous or synchronous).

ForcePortIpAddress As String

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".

Greeting As String (read-only)

The initial greeting received from the FTP server after connecting.

HasModeZ As Long (read-only)

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). This is a read-only property. It will be set to 1 if the FTP2 component detects that your FTP server supports MODE Z. Otherwise it is set to 0.

HeartbeatMs As Long

This is the number of milliseconds between each AbortCheck event callback. The AbortCheck callback allows an application to abort any FTP operation prior to completion. If HeartbeatMs is 0, no AbortCheck event callbacks will occur. Also, AbortCheck callbacks do not occur when doing asynchronous transfers.

Hostname As String

The domain name of the FTP server. May also use the IPv4 or IPv6 address in string format.

IdleTimeoutMs As Long

Forces a timeout when a response is expected on the control channel, but no response arrives for this number of milliseconds. Setting IdleTimeoutMs = 0 allows the application to wait indefinitely. The default value is 60000 (i.e. 60 seconds).

IsConnected As Long (read-only)

Returns 1 if currently connected and logged into an FTP server, otherwise returns 0.

Note: Accessing this property may cause a NOOP command to be sent to the FTP server.

KeepSessionLog As Long

Turns the in-memory session logging on or off. If on, the session log can be obtained via the SessionLog property.

LastErrorHtml As String (read-only)

The last-error information returned in an HTML formatted string.Error information in HTML format for the last method called.

LastErrorText As String (read-only)

The last-error information returned in a plain-text string with CRLF line-endings.Error information in plain-text format for the last method called.

LastErrorXml As String (read-only)

The last-error information returned in an XML formatted string.Error information in XML format for the last method called.

ListPattern As String

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".

LoginVerified As Long (read-only)

True if the FTP2 component was able to login to the FTP server after calling Connect.

NumFilesAndDirs As Long (read-only)

The number of files and sub-directories in the current remote directory that match the ListPattern. (The ListPattern defaults to "*", so unless changed, this is the total number of files and sub-directories.)

Important: Accessing this property can cause the directory listing to be retrieved from the FTP server. For FTP servers that doe not support the MLST/MLSD commands, this is technically a data transfer that requires a temporary data connection to be established in the same way as when uploading or downloading files. If your program hangs while accessing NumFilesAndDirs, it probably means that the data connection could not be established. The most common solution is to switch to using Passive mode by setting the Passive property = 1. If this does not help, examine the contents of the LastErrorText property after NumFilesAndDirs finally returns (after timing out). Also, see this Chilkat blog post about FTP connection settings.

Special considerations.

PartialTransfer As Long (read-only)

A read-only property that indicates whether a partial transfer was received in the last method call to download a file. Set to 1 if a partial transfer was received. Set to 0 if nothing was received, or if the full file was received.

Passive As Long

Set to true for FTP to operate in passive mode, otherwise set to false for non-passive (the default).

PassiveUseHostAddr As Long

This can handle problems that may arise when an FTP server is located behind a NAT router. FTP servers respond to the PASV command by sending the IP address and port where it will be listening for the data connection. If the control connection is SSL encrypted, the NAT router is not able to convert from an internal IP address (typically beginning with 192.168) to an external address. When set to 1, PassiveUseHostAddr property tells the FTP client to discard the IP address part of the PASV response and replace it with the IP address of the already-established control connection. The default value of this property is 0.

Password As String

Password for logging into the FTP server.

Port As Long

Port number. Automatically defaults to the default port for the FTP service.

PreferNlst As Long

If 1, the NLST command is used instead of LIST when fetching a directory listing. This can help in very rare cases where the FTP server returns truncated filenames. The drawback to using NLST is that it won’t return size or date/time info (but it should return the full filename).

The default value of this property is 0.

ProgressMonSize As Long

Progress monitoring for FTP downloads rely on the FTP server indicating the file size within the RETR response. Some FTP servers however, do not indicate the file size and therefore it is not possible to monitor progress based on percentage completion. This property allows the application to explicitly tell the FTP component the size of the file about to be downloaded for the next GetFile call.

(VB6) ProgressMonSize (more info and example)

(Delphi) ProgressMonSize (more info and example)

(FoxPro) ProgressMonSize (more info and example)

(VBScript) ProgressMonSize (more info and example)

ProxyHostname As String

The hostname of your FTP proxy, if a proxy server is used.

ProxyMethod As Long

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

ProxyPassword As String

The password for authenticating with the FTP proxy server.

ProxyPort As Long

If an FTP proxy server is used, this is the port number at which the proxy server is listening for connections.

ProxyUsername As String

The username for authenticating with the FTP proxy server.

ReadTimeout As Long

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.

RequireSslCertVerify As Long

If 1, 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 0.

RestartNext As Long

Both uploads and downloads may be resumed by simply setting this property = 1 and re-calling the upload or download method.

(ASP) Example: Restart/Resume FTP Download

(VB6) Example: Restart/Resume FTP Download

(Delphi) Example: Restart/Resume FTP Download

(FoxPro) Example: Restart/Resume FTP Download

(PHP using ActiveX) Example: Restart/Resume FTP Download

(VBScript) Example: Restart/Resume FTP Download

(ASP) Example: Restart/Resume FTP Upload

(VB6) Example: Restart/Resume FTP Upload

(Delphi) Example: Restart/Resume FTP Upload

(FoxPro) Example: Restart/Resume FTP Upload

(PHP using ActiveX) Example: Restart/Resume FTP Upload

(VBScript) Example: Restart/Resume FTP Upload

SendBufferSize As Long

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).

SessionLog As String (read-only)

Contains the session log if KeepSessionLog is turned on.

SkipFinalReply As Long

Special property used to help specific customers with a certain type of embedded FTP server. Do not use unless advised by Chilkat.

SocksHostname As String

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).

SocksPassword As String

The SOCKS5 password (if required). The SOCKS4 protocol does not include the use of a password, so this does not apply to SOCKS4.

SocksPort As Long

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).

SocksUsername As String

The SOCKS4/SOCKS5 proxy username. This property is only used if the SocksVersion property is set to 4 or 5).

SocksVersion As Long

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.

Ssl As Long

Use TLS/SSL for FTP connections. You would typically set Ssl = 1 when connecting to port 990 on FTP servers that support TLS/SSL mode. Note: It is more common to use AuthTls.

SslProtocol As String

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.

SslServerCertVerified As Long (read-only)

Read-only property that returns 1 if the FTP server's digital certificate was verified when connecting via SSL / TLS.

SyncPreview As String (read-only)

Contains the list of files that would be transferred in a call to SyncRemoteTree2 when the previewOnly argument is set to 1. 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.

UploadRate As Long (read-only)

The average upload rate in bytes/second. This property is updated in real-time during any FTP upload (asynchronous or synchronous).

UseEpsv As Long

If 1, the FTP2 component will use the EPSV command instead of PASV for passive mode data transfers. The default value of this property is 0. (It is somewhat uncommon for FTP servers to support EPSV.)

Username As String

Username for logging into the FTP server. Defaults to "anonymous".

VerboseLogging As Long

If set to 1, then the LastErrorText may contain more verbose logging.

Version As String (read-only)

Version of the component, such as "1.0.0"

Methods

AppendFile(localFilePath As String, remoteFilePath As String) As Long

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 1 for success, 0 for failure.

AppendFileFromBinaryData(remoteFilename As String, binaryData As Variant) As Long

Same as PutFileFromBinaryData, except the file on the FTP server is appended.

Returns 1 for success, 0 for failure.

AppendFileFromTextData(remoteFilename As String, textData As String, charset As String) As Long

Same as PutFileFromTextData, except the file on the FTP server is appended.

Returns 1 for success, 0 for failure.

AsyncAbort()

Causes an asynchronous Get or Put to abort.

AsyncAppendFileStart(localFilename As String, remoteFilename As String) As Long

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 1 for success, 0 for failure.

AsyncGetFileStart(remoteFilename As String, localFilename As String) As Long

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 1 for success, 0 for failure.

AsyncPutFileStart(localFilename As String, remoteFilename As String) As Long

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 1 for success, 0 for failure.

ChangeRemoteDir(remoteDirPath As String) As Long

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 1 for success, 0 for failure.

ClearControlChannel() As Long

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 1 for success, 0 for failure.

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.

ClearSessionLog()

Clears the in-memory session log.

Connect() As Long

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 0 (indicating failure).

Returns 1 for success, 0 for failure.

ConvertToTls() As Long

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 1, 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.

CreatePlan(localDir As String) As String

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

CreateRemoteDir(remoteDirPath As String) As Long

Creates a directory on the FTP server. If the directory already exists, a new one is not created and 0 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 1 for success, 0 for failure.

DeleteMatching(remotePattern As String) As Long

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.

DeleteRemoteFile(remoteFilePath As String) As Long

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 1 for success, 0 for failure.

DeleteTree() As Long

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 1 for success, 0 for failure.

(ASP) Delete FTP Directory Tree

(VB6) Delete FTP Directory Tree

(Delphi) Delete FTP Directory Tree

(FoxPro) Delete FTP Directory Tree

(PHP using ActiveX) Delete FTP Directory Tree

(VBScript) Delete FTP Directory Tree

DetermineProxyMethod() As Long

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.)

(ASP) Automatically Determine FTP Proxy Method

(VB6) Automatically Determine FTP Proxy Method

(Delphi) Automatically Determine FTP Proxy Method

(FoxPro) Automatically Determine FTP Proxy Method

(PHP using ActiveX) Automatically Determine FTP Proxy Method

(VBScript) Automatically Determine FTP Proxy Method

DetermineSettings() As String

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

(ASP) DetermineSettings Example

(VB6) DetermineSettings Example

(Delphi) DetermineSettings Example

(FoxPro) DetermineSettings Example

(PHP using ActiveX) DetermineSettings Example

(VBScript) DetermineSettings Example

DirTreeXml() As String

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

(ASP) Download Directory Tree Listing as XML

(VB6) Download Directory Tree Listing as XML

(Delphi) Download Directory Tree Listing as XML

(FoxPro) Download Directory Tree Listing as XML

(PHP using ActiveX) Download Directory Tree Listing as XML

(VBScript) Download Directory Tree Listing as XML

Disconnect()

Disconnects from the FTP server, ending the current session.

Returns 1 for success, 0 for failure.

DownloadTree(localFilename As String) As Long

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 1 for success, 0 for failure.

(ASP) Download Directory Tree Listing as XML

(VB6) Download Directory Tree Listing as XML

(Delphi) Download Directory Tree Listing as XML

(FoxPro) Download Directory Tree Listing as XML

(PHP using ActiveX) Download Directory Tree Listing as XML

(VBScript) Download Directory Tree Listing as XML

Feat() As String

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

(ASP) FTP FEAT Command

(VB6) FTP FEAT Command

(Delphi) FTP FEAT Command

(FoxPro) FTP FEAT Command

(PHP using ActiveX) FTP FEAT Command

(VBScript) FTP FEAT Command

GetCreateTime(index As Long) As Date

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)

GetCreateTimeByName(filename As String) As Date

Returns the file-creation time for a remote file by filename.

GetCurrentRemoteDir() As String

Returns the current remote directory.

Returns a null on failure

GetFile(remoteFilePath As String, localFilePath As String) As Long

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 1 for success, 0 for failure.

GetFilename(index As Long) As String

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

GetIsDirectory(index As Long) As Long

Returns 1 for a sub-directory and 0 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)

GetIsSymbolicLink(index As Long) As Long

Returns 1 if the remote file is a symbolic link. (Symbolic links only exist on Unix/Linux systems, not on Windows filesystems.)

GetLastAccessTime(index As Long) As Date

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)

GetLastAccessTimeByName(filename As String) As Date

Returns a remote file's last-access time.

GetLastModifiedTime(index As Long) As Date

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)

GetLastModifiedTimeByName(filename As String) As Date

Returns the last-modified date/time for a remote file.

GetRemoteFileBinaryData(remoteFilename As String) As Variant

Downloads the contents of a remote file into a byte array.

Returns an empty Variant on failure.

Returns a zero-length byte array (as a Variant) on failure.
An empty array will have a UBound of -1 meaning 0 elements.

GetRemoteFileTextC(remoteFilename As String, charset As String) As String

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

GetRemoteFileTextData(remoteFilename As String) As String

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

GetSize(index As Long) As Long

Returns the size of the Nth remote file in the current directory.

GetSizeByName(filename As String) As Long

Returns a remote file's size in bytes.

GetSizeStr(index As Long) As String

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

GetSizeStrByName(filename As String) As String

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

GetSslServerCert() As ChilkatCert

Returns the FTP server's digital certificate (for SSL / TLS connections).

GetTextDirListing(pattern As String) As String

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

GetXmlDirListing(pattern As String) As String

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

IsUnlocked() As Long

Return true if the component is already unlocked.

MGetFiles(remotePattern As String, localDir As String) As Long

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.

MPutFiles(pattern As String) As Long

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.[

NlstXml(remoteDirPattern As String) As String

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

Noop() As Long

Issues a no-op command to the FTP server.

PutFile(localFilePath As String, remoteFilePath As String) As Long

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 1 for success, 0 for failure.

PutFileFromBinaryData(remoteFilename As String, binaryData As Variant) As Long

Creates a file on the remote server containing the data passed in a byte array.

Returns 1 for success, 0 for failure.

PutFileFromTextData(remoteFilename As String, textData As String, charset As String) As Long

Creates a file on the remote server containing the data passed in a string.

Returns 1 for success, 0 for failure.

PutPlan(planStr As String, planLogFilename As String) As Long

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 1 for success, 0 for failure.

PutTree(localDir As String) As Long

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 1 for success, 0 for failure.

Quote(cmd As String) As Long

Sends an arbitrary (raw) command to the FTP server.

Returns 1 for success, 0 for failure.

(ASP) Quote Example

(VB6) Quote Example

(Delphi) Quote Example

(FoxPro) Quote Example

(PHP using ActiveX) Quote Example

(VBScript) Quote Example

RemoveRemoteDir(remoteDirPath As String) As Long

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.

RenameRemoteFile(existingRemoteFilePath As String, newRemoteFilePath As String) As Long

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.

SaveLastError(filename As String)

Saves the last error information to an XML formatted file.

SendCommand(rawCommand As String) As String

Sends an raw command to the FTP server and returns the raw response.

Returns a null on failure

(ASP) SendCommand Example

(VB6) SendCommand Example

(Delphi) SendCommand Example

(FoxPro) SendCommand Example

(PHP using ActiveX) SendCommand Example

(VBScript) SendCommand Example

SetModeZ() As Long

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 1 for success, 0 for failure.

SetOldestDate(oldestDateTime As Date)

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.

SetRemoteFileDateTime(dt As Date, remoteFilename As String) As Long

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.

SetSslCertRequirement(reqName As String, reqValue As String)

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.

SetSslClientCert(iCert As ChilkatCert)

Allows for a client-side certificate to be used for the SSL / TLS connection.

Returns 1 for success, 0 for failure.

SetSslClientCertPem(pemDataOrFilename As String, pemPassword As String) As Long

Allows for a client-side certificate to be used for the SSL / TLS connection.

Returns 1 for success, 0 for failure.

SetSslClientCertPfx(pfxFilename As String, pfxPassword As String, certSubjectCN As String) As Long

Allows for a client-side certificate to be used for the SSL / TLS connection.

Returns 1 for success, 0 for failure.

SetTypeAscii() As Long

Set the FTP transfer mode to us-ascii.

Returns 1 for success, 0 for failure.

SetTypeBinary() As Long

Set the FTP transfer mode to binary.

Returns 1 for success, 0 for failure.

Site(params As String) As Long

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 1 for success, 0 for failure.

SleepMs(milliSec As Long)

Causes the calling process to sleep for a number of milliseconds.

Stat() As String

Sends a STAT command to the FTP server and returns the server's reply.

Returns a null on failure

SyncLocalTree(localDirRoot As String, mode As Long) As Long

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 1 for success, 0 for failure.

(ASP) Example: Synchronize Local Directory Tree

(VB6) Example: Synchronize Local Directory Tree

(Delphi) Example: Synchronize Local Directory Tree

(FoxPro) Example: Synchronize Local Directory Tree

(PHP using ActiveX) Example: Synchronize Local Directory Tree

(VBScript) Example: Synchronize Local Directory Tree

SyncRemoteTree(localDirRoot As String, mode As Long) As Long

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 1 for success, 0 for failure.

(ASP) Example: Synchronize Remote Directory Tree

(VB6) Example: Synchronize Remote Directory Tree

(Delphi) Example: Synchronize Remote Directory Tree

(FoxPro) Example: Synchronize Remote Directory Tree

(PHP using ActiveX) Example: Synchronize Remote Directory Tree

(VBScript) Example: Synchronize Remote Directory Tree

SyncRemoteTree2(localDirPath As String, mode As Long, bDescend As Long, bPreviewOnly As Long) As Long

Same as SyncRemoteTree, except two extra arguments are added to allow for more flexibility. If bDescend is 0, then the directory tree is not descended and only the files in localDirPath are synchronized. If bPreviewOnly is 1 then no files are transferred and instead the files that would've been transferred (had bPreviewOnly been set to 0) are listed in the SyncPreview property.

Returns 1 for success, 0 for failure.

Syst() As String

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

UnlockComponent(b1 As String) As Long

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