WebClient.UploadFileCompleted Evento

Definizione

Si verifica al completamento di un'operazione asincrona di upload di file.

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

Tipo evento

UploadFileCompletedEventHandler

Esempio

Nell'esempio di codice seguente viene illustrata l'impostazione di un gestore eventi per questo evento.

// 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

Commenti

Questo evento viene generato ogni volta che viene completata un'operazione di caricamento di file asincrona. I caricamenti di file asincroni vengono avviati chiamando i UploadFileAsync metodi .

UploadFileCompletedEventHandler è il delegato per questo evento. La UploadFileCompletedEventArgs classe fornisce al gestore eventi i dati dell'evento.

Per altre informazioni su come gestire gli eventi, vedere la gestione e generazione di eventi.

Si applica a