WebClient.UploadFileCompleted WebClient.UploadFileCompleted WebClient.UploadFileCompleted WebClient.UploadFileCompleted Event

Définition

Se produit lors d'une opération asynchrone de transfert de fichiers.Occurs when an asynchronous file-upload operation completes.

public:
 event System::Net::UploadFileCompletedEventHandler ^ UploadFileCompleted;
public event System.Net.UploadFileCompletedEventHandler UploadFileCompleted;
member this.UploadFileCompleted : System.Net.UploadFileCompletedEventHandler 
Public Custom Event UploadFileCompleted As UploadFileCompletedEventHandler 

Exemples

L’exemple de code suivant montre comment définir un gestionnaire d’événements pour cet événement.The following code example demonstrates setting an event handler for this event.

// Sample call: UploadFileInBackground2("http://www.contoso.com/fileUpload.aspx", "data.txt")
void UploadFileInBackground2( String^ address, String^ fileName )
{
   WebClient^ client = gcnew WebClient;
   Uri ^uri = gcnew Uri(address);

   client->UploadFileCompleted += 
     gcnew UploadFileCompletedEventHandler (UploadFileCallback2);
   
   // Specify a progress notification handler.
   client->UploadProgressChanged += 
       gcnew UploadProgressChangedEventHandler( UploadProgressCallback );
   client->UploadFileAsync( uri, "POST", fileName );
   Console::WriteLine( "File upload started." );
}


  // Sample call: UploadFileInBackground2("http://www.contoso.com/fileUpload.aspx", "data.txt")
  public static void UploadFileInBackground2 (string address, string fileName)
  {
      WebClient client = new WebClient ();
      Uri uri = new Uri(address);

      client.UploadFileCompleted += new UploadFileCompletedEventHandler (UploadFileCallback2);

// Specify a progress notification handler.
client.UploadProgressChanged += new UploadProgressChangedEventHandler(UploadProgressCallback);
      client.UploadFileAsync (uri, "POST", fileName);
      Console.WriteLine ("File upload started.");
  }

'  Sample call: UploadFileInBackground2("http:' www.contoso.com/fileUpload.aspx", "data.txt")
Public Shared Sub UploadFileInBackground2(ByVal address As String, ByVal fileName As String)

	Dim client As WebClient = New WebClient()
                      Dim uri as Uri =  New Uri(address)
	AddHandler client.UploadFileCompleted, AddressOf UploadFileCallback2

	'  Specify a progress notification handler.
	AddHandler client.UploadProgressChanged, AddressOf UploadProgressCallback
	client.UploadFileAsync(uri, "POST", fileName)
	Console.WriteLine("File upload started.")
End Sub

Remarques

Cet événement est déclenché chaque fois qu’une opération de chargement de fichier asynchrone se termine.This event is raised each time an asynchronous file upload operation completes. Les téléchargements asynchrones de fichiers sont démarrés en UploadFileAsync appelant les méthodes.Asynchronous file uploads are started by calling the UploadFileAsync methods.

Le UploadFileCompletedEventHandler est le délégué de cet événement.The UploadFileCompletedEventHandler is the delegate for this event. La UploadFileCompletedEventArgs classe fournit le gestionnaire d’événements avec les données d’événement.The UploadFileCompletedEventArgs class provides the event handler with event data.

Pour plus d’informations sur la façon de gérer les événements, consultez gestion et déclenchement d’événements.For more information about how to handle events, see Handling and Raising Events.

S’applique à