共用方式為


Send

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Executes a download request.

downloaderObject.Send()

Managed Equivalent

Managed programming does not use Downloader. See WebClient.

Remarks

The Send method executes the request to download data by using the Downloader object. The Send method executes asynchronously. If you need to know exactly when the requested content will be available, you should attach a handler for the Completed event before you call Send.

Cross-domain download attempts or attempts to download through the FILE scheme will fail without raising the Completed or DownloadFailed events. In these cases, the Send method will fail.

Example

The following JavaScript example shows how to invoke the Send method.

// Event handler for initializing and executing a download request.
function onMouseLeftButtonUp(sender, eventArgs)
{
    // Retrieve a reference to the plug-in.
    var slPlugin = sender.getHost();

    // Create a Downloader object.
    var downloader = slPlugin.createObject("downloader");

    // Add DownloadProgressChanged and Completed events.
    downloader.addEventListener("downloadProgressChanged", onDownloadProgressChanged);
    downloader.addEventListener("completed", onCompleted);

    // Initialize the Downloader request.
    // Note: Downloader APIs disallow file:\\ scheme.
    // You must run this sample over localhost: or off a server; otherwise, the following call will fail.

    downloader.open("GET", "promo.png");

    // Execute the Downloader request.
    downloader.send();
}

Applies To

Downloader

See Also

Reference