Bagikan melalui


UploadFileCompletedEventArgs Kelas

Definisi

Menyediakan data untuk peristiwa tersebut UploadFileCompleted .

public ref class UploadFileCompletedEventArgs : System::ComponentModel::AsyncCompletedEventArgs
public class UploadFileCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs
type UploadFileCompletedEventArgs = class
    inherit AsyncCompletedEventArgs
Public Class UploadFileCompletedEventArgs
Inherits AsyncCompletedEventArgs
Warisan
UploadFileCompletedEventArgs

Contoh

Contoh kode berikut menunjukkan pengunggahan file secara asinkron.

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

Metode berikut dipanggil ketika unggahan selesai.

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

Keterangan

Instans kelas ini diteruskan ke UploadFileCompletedEventHandler.

Properti

Cancelled

Mendapatkan nilai yang menunjukkan apakah operasi asinkron telah dibatalkan.

(Diperoleh dari AsyncCompletedEventArgs)
Error

Mendapatkan nilai yang menunjukkan kesalahan mana yang terjadi selama operasi asinkron.

(Diperoleh dari AsyncCompletedEventArgs)
Result

Mendapatkan balasan server ke operasi pengunggahan data yang dimulai dengan memanggil UploadFileAsync metode .

UserState

Mendapatkan pengidentifikasi unik untuk tugas asinkron.

(Diperoleh dari AsyncCompletedEventArgs)

Metode

Equals(Object)

Menentukan apakah objek yang ditentukan sama dengan objek saat ini.

(Diperoleh dari Object)
GetHashCode()

Berfungsi sebagai fungsi hash default.

(Diperoleh dari Object)
GetType()

Mendapatkan instans Type saat ini.

(Diperoleh dari Object)
MemberwiseClone()

Membuat salinan dangkal dari yang saat ini Object.

(Diperoleh dari Object)
RaiseExceptionIfNecessary()

Meningkatkan pengecualian yang disediakan pengguna jika operasi asinkron gagal.

(Diperoleh dari AsyncCompletedEventArgs)
ToString()

Mengembalikan string yang mewakili objek saat ini.

(Diperoleh dari Object)

Berlaku untuk