WebClient.UploadFileCompleted Olay

Tanım

Zaman uyumsuz bir dosya yükleme işlemi tamamlandığında gerçekleşir.

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 

Olay Türü

Örnekler

Aşağıdaki kod örneği, bu olay için bir olay işleyicisi ayarlamayı gösterir.

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

Aşağıdaki kod örneği, bu olay için bir işleyicinin uygulamasını gösterir.

void UploadFileCallback2( Object^ /*sender*/, UploadFileCompletedEventArgs^ e )
{
   String^ reply = System::Text::Encoding::UTF8->GetString( e->Result );
   Console::WriteLine( reply );
}
private static void UploadFileCallback2(Object sender, UploadFileCompletedEventArgs e)
{
    string reply = System.Text.Encoding.UTF8.GetString(e.Result);
    Console.WriteLine(reply);
}
Private Shared Sub UploadFileCallback2(ByVal sender As Object, ByVal e As System.Net.UploadFileCompletedEventArgs)

    Dim reply As String = System.Text.Encoding.UTF8.GetString(e.Result)
    Console.WriteLine(reply)
End Sub

Açıklamalar

Bu olay, zaman uyumsuz bir dosya karşıya yükleme işlemi her tamamlandığında oluşturulur. Zaman uyumsuz dosya yüklemeleri yöntemleri çağrılarak UploadFileAsync başlatılır.

UploadFileCompletedEventHandler bu olayın temsilcisidir. sınıfı, UploadFileCompletedEventArgs olay işleyicisine olay verilerini sağlar.

Olayları işleme hakkında daha fazla bilgi için bkz. Olayları İşleme ve Oluşturma.

Şunlara uygulanır