Previous | Next

AddFile Method

Adds a file to the list of files to be downloaded.

Long AddFile(
     String url,
     String fileSize,
     String displayFileName,
     String savePath,
     Long segmentCount,
     String referer,
     String userName,
     String password,
     Integer options
)

Parameters

url
Type: String
The URL of the file to be downloaded. The url must start with one of the following network protocol designators:

  • "http://" - HTTP protocol
  • "https://" - HTTPS protocol (secure HTTP, HTTP over SSL)
  • "ftp://" - FTP protocol
  • "ftps://" - Secure FTP, FTP over SSL

fileSize
Type: String
The file size (in bytes) of the file to be downloaded. The value specified is initially displayed in the File Size column in the file list while the file is waiting to be downloaded, it can also be set to "-1". Once the file starts downloading from the server, the File Size column in the file list is updated with the real file size. Even though the fileSize is of String type (to support large file sizes - up to 263 bytes), valid values are integer values specifying the file size in bytes.

displayFileName
Type: String
Friendly file name that is displayed in the File Name column in the file list. It can also be set to "" (empty string) in which case the file name taken from the url is displayed in the File Name column in the file list.

savePath
Type: String
The save path of the downloaded file. The savePath can be of the following forms:

  • "" or "\" - The dialog box will appear where the user will choose the save folder and file name.
  • "\{save_file_name}" - The dialog box will appear where the user will choose the save folder for the specified save file name {save_file_name}. If the CommonSaveFolder property is set to true, then the save folder choosen will be used for all files in the file list with this form of the savePath parameter, meaning the dialog box for choosing folder will appear only once.
  • "{save_folder}\" - The specified save folder {save_folder} will be used and the save file name will be taken from the url parameter. No dialog box is displayed.
  • "{save_folder_and_file_name}" - The specified save folder and file name {save_folder_and_file_name} will be used. No dialog box is displayed.

segmentCount
Type: Long
The number of segments the file is split into before it gets downloaded. Each file segment is downloaded in a separate thread at the same time in order to speed up file download. The value of 2 to 3 file segments should be fine in most cases. But please note that sometimes when downloading huge files, depending on the server and its settings, specifying number of segments greater than 1 can introduce initial delay on the server of up to few minutes before download will begin. The MinFileSegmentSize property designates the minimum segment size which is used to prevent splitting files into segments smaller than this value.

referer
Type: String
The referer parameter used in HTTP/HTTPS requests. It can also be set to "" (empty string).

userName
Type: String
The user name of the login credentials in case authentication is required on the server, otherwise set it to "" (empty string).

password
Type: String
The password of the login credentials in case authentication is required on the server, otherwise set it to "" (empty string).

options
Type: Integer
The additional options:

  • 0 - Explicit FTPS is used if the url parameter designates secure FTP (FTPS) protocol.
  • 1 - Implicit FTPS is used if the url parameter designates secure FTP (FTPS) protocol.
In all other cases, the options parameter is not important and can be set to 0.

Return Value

Type: Long

If the method succeeds, the return value is a file ID which can be used with other DownloadX methods to retrieve additional information for a file. If the method fails, the return value is -1. To get extended error information, call GetLastError and GetLastErrorDesc methods.

Examples

For an example, see Downloading files with the DownloadX control.