WebClient.UploadFileCompleted Zdarzenie

Definicja

Występuje po zakończeniu asynchronicznej operacji przekazywania pliku.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 Event UploadFileCompleted As UploadFileCompletedEventHandler 

Przykłady

Poniższy przykład kodu demonstruje ustawienie programu obsługi zdarzeń dla tego zdarzenia.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

Uwagi

To zdarzenie jest zgłaszane przy każdym zakończeniu asynchronicznej operacji przekazywania pliku.This event is raised each time an asynchronous file upload operation completes. Asynchroniczne operacje przekazywania plików są uruchamiane przez wywołanie metod UploadFileAsync.Asynchronous file uploads are started by calling the UploadFileAsync methods.

UploadFileCompletedEventHandler jest delegatem dla tego zdarzenia.The UploadFileCompletedEventHandler is the delegate for this event. Klasa UploadFileCompletedEventArgs udostępnia obsługę zdarzeń z danymi zdarzenia.The UploadFileCompletedEventArgs class provides the event handler with event data.

Aby uzyskać więcej informacji o sposobie obsługi zdarzeń, zobacz Obsługa iwywoływanie zdarzeń.For more information about how to handle events, see Handling and Raising Events.

Dotyczy