System.Net.WebClient.DownloadProgressChanged Event

Occurs when an asynchronous download operation successfully transfers some or all of the data.

Syntax

public event DownloadProgressChangedEventHandler DownloadProgressChanged

Remarks

This event is raised each time an asynchronous download makes progress. This event is raised when downloads are started using any of the following methods.

WebClient.DownloadDataAsync(Uri)

Downloads data from a resource and returns a byte array, without blocking the calling thread.

WebClient.DownloadFileAsync(Uri, string)

Downloads data from a resource to a local file, without blocking the calling thread.

WebClient.OpenReadAsync(Uri)

Returns the data from a resource, without blocking the calling thread.

The System.Net.DownloadProgressChangedEventHandler is the delegate for this event. The System.Net.DownloadProgressChangedEventArgs class provides the event handler with event data.

For more information about handling events, see Consuming Events.

Note:

A passive FTP file transfer will always show a progress percentage of zero, since the server did not send the file size. To show progress, you can change the FTP connection to active by overriding the WebClient.GetWebRequest(Uri) virtual method:

Example

internal class MyWebClient:WebClient{
        protected override WebRequest GetWebRequest(Uri address) {
            FtpWebRequest req = (FtpWebRequest)base.GetWebRequest(address);
            req.UsePassive = false;
            return req;
        }
    }

Requirements

Namespace: System.Net
Assembly: System (in System.dll)
Assembly Versions: 2.0.0.0, 4.0.0.0