WebClient.DownloadFileCompleted WebClient.DownloadFileCompleted WebClient.DownloadFileCompleted WebClient.DownloadFileCompleted Event

Definition

Tritt ein, wenn ein asynchroner Dateidownload abgeschlossen wird.Occurs when an asynchronous file download operation completes.

public:
 event System::ComponentModel::AsyncCompletedEventHandler ^ DownloadFileCompleted;
public event System.ComponentModel.AsyncCompletedEventHandler DownloadFileCompleted;
member this.DownloadFileCompleted : System.ComponentModel.AsyncCompletedEventHandler 
Public Custom Event DownloadFileCompleted As AsyncCompletedEventHandler 

Beispiele

Im folgenden Codebeispiel wird das Festlegen eines Ereignis Handlers für dieses Ereignis veranschaulicht.The following code example demonstrates setting an event handler for this event.

// Sample call : DownLoadFileInBackground2 ("http://www.contoso.com/logs/January.txt");
void DownLoadFileInBackground2( String^ address )
{
   WebClient^ client = gcnew WebClient;
   Uri ^uri = gcnew Uri(address);
   
   // Specify that the DownloadFileCallback method gets called
   // when the download completes.
   client->DownloadFileCompleted += gcnew AsyncCompletedEventHandler( DownloadFileCallback2 );
   
   // Specify a progress notification handler.
   client->DownloadProgressChanged += gcnew DownloadProgressChangedEventHandler( DownloadProgressCallback );
   client->DownloadFileAsync( uri, "serverdata.txt" );
}


// Sample call : DownLoadFileInBackground2 ("http://www.contoso.com/logs/January.txt");
public static void DownLoadFileInBackground2 (string address)
{
    WebClient client = new WebClient ();
    Uri uri = new Uri(address);

    // Specify that the DownloadFileCallback method gets called
    // when the download completes.
    client.DownloadFileCompleted += new AsyncCompletedEventHandler (DownloadFileCallback2);
    // Specify a progress notification handler.
    client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(DownloadProgressCallback);
    client.DownloadFileAsync (uri, "serverdata.txt");
}

'  Sample call : DownLoadFileInBackground2 ("http:' www.contoso.com/logs/January.txt")
Public Shared Sub DownLoadFileInBackground2(ByVal address As String)

	Dim client As WebClient = New WebClient()

	'  Specify that the DownloadFileCallback method gets called
	'  when the download completes.
	AddHandler client.DownloadFileCompleted, AddressOf DownloadFileCallback2
	'  Specify a progress notification handler.
	AddHandler client.DownloadProgressChanged, AddressOf DownloadProgressCallback
                      Dim uri as Uri = New Uri(address)
	client.DownloadFileAsync(uri, "serverdata.txt")
End Sub

Hinweise

Dieses Ereignis wird jedes Mal ausgelöst, wenn ein asynchroner Datei Downloadvorgang abgeschlossen ist.This event is raised each time an asynchronous file download operation completes. Asynchrone Dateidownloads werden gestartet, indem die DownloadFileAsync -Methoden aufgerufen werden.Asynchronous file downloads are started by calling the DownloadFileAsync methods.

Der AsyncCompletedEventHandler ist der Delegat für dieses Ereignis.The AsyncCompletedEventHandler is the delegate for this event. Die AsyncCompletedEventArgs -Klasse stellt den Ereignishandler für Ereignisdaten bereit.The AsyncCompletedEventArgs class provides the event handler with event data.

Weitere Informationen zum Behandeln von Ereignissen finden Sie unter behandeln und Auslösen von Ereignissen.For more information about how to handle events, see Handling and Raising Events.

Gilt für: