Downloading Items Asynchronously (DownloadAsync)

Use the DownloadAsync method to download a file or folder to the local hard drive asynchronously. An asynchronous download starts and then returns control to the script before the transfer finishes. This allows you to perform many simultaneous transfers because the method does not wait for the download to end. Immediately after you call this method subsequent methods in your script will be called, so be careful when timing certain events.

If DownloadAsync encounters a problem when trying to complete its task, it will not throw a COM, ATL, or VB error. DownloadAsync will also adhere to your max global and per site settings.

Syntax

Object.DownloadAsync(BSTR strRemoteName ,BSTR strLocalName , long nMultiPartNumber)

Parameters

strLocalName

This is optional, use it only if you want to change the destination name or path for the downloaded files or folder. You can use absolute or relative paths with or without wildcards.

strRemoteName

This is the path to the remote item you are downloading. You can use absolute or relative paths with or without wildcards.

nMultiPartNumber

Use this to split the download into multiple parts. The default value = 1. The value specifies the number of parts used for the download.

Example

Set MySite = CreateObject("CuteFTPPro.TEConnection")

MySite.Host = "ftp.cuteftp.com"

MySite.Connect

MySite.DownloadAsync "/pub/cuteftp/english/*", "c:\temp" 'downloads all files in the pub/cuteftp folder 

 

You can call the DownloadAsync method many times sequentially in a script. Each call, in turn, opens a new data connection to the specified server, enabling you to transfer multiple files simultaneously. This, combined with the ability to transfer the file in multiple parts, greatly increases the overall transfer speed and execution of your task.