mobileFX WebKitX CEF3 ActiveX 4.x
WebKitXCEF3Lib ActiveX Control / WebKitXCEF3 Object / Download Method

The URL of the File to Download.

In This Topic
    Download Method
    In This Topic
    Description

    Downloads a File.

    Syntax
    Visual Basic
    Public Sub Download( _
       ByVal url As String _
    ) 
    Parameters
    url

    The URL of the File to Download.

    Remarks

    Download method will start downloading of a resource defined by the URL. During file download the OnBeforeDownload event is fired once, followed by OnDownloadUpdated events, until the resource if fully downloaded or cancelled. To set the local Path and FileName of the resource being downloaded you need to handle OnBeforeDownload and set the relevant parameters. You may cancel the download of the resource by handling OnBeforeDownload and setting Cancel parameter to True.

    You can set the Path and FileName or cancel the download by calling SetDownloadPath method while in OnBeforeDownload event. This is best practice for programming languages that cannot handle ByRef arguments. You can define a master download path for all your downloads by handling OnCreate event and setting Settings.default_download_path to your downloads folder.

    If the resource is loaded from the Cache then OnBeforeDownload and OnDownloadUpdated events will not fire. You can control cache by handling OnCreate event and setting Settings.cache_path folder. You are advised to use a different WebKitX control instance for downloading resources with its own cache that you should delete once the resource is downloaded.

    If the resource is of type PDF and the Plugins are enabled, the document will be loaded in PDF Viewer instead of downloaded; in this case no download events are fired. To download PDF files you need to create WebKitX browser without enabling any plugins. To do that you need to handle the OnCreate event and set Settings.plugins = false and append --disable-pdf-extension=1 in OnCreate command line switches.

    Example
    Private Sub mnuDownload_Click()
        On Error Resume Next
        Dim s As String
        s = InputBox("Download File URL:", , "https://www.webkitx.com/WebKitX_CEF3_ActiveX_1.1.9.1977.exe")
        If s = "" Then Exit Sub
        WebKitX1.Download s
        If Err.Number Then
            MsgBox Err.Description, vbCritical
        End If
    End Sub
    private void menuItemDownloadURL_Click(object sender, EventArgs e)
    {
        string input = Microsoft.VisualBasic.Interaction.InputBox("Download File URL:", "HTML5 Pad", "https://www.webkitx.com/WebKitX_CEF3_ActiveX_1.5.11.3454.exe", 500, 300);
        if (input != "")
        {
            WebKitXCEF31.Download(input);
        }
    }
    See Also