UploadFileCompletedEventArgs UploadFileCompletedEventArgs UploadFileCompletedEventArgs UploadFileCompletedEventArgs Class

Определение

Предоставляет данные для события UploadFileCompleted.Provides data for the UploadFileCompleted event.

public ref class UploadFileCompletedEventArgs : System::ComponentModel::AsyncCompletedEventArgs
public class UploadFileCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs
type UploadFileCompletedEventArgs = class
    inherit AsyncCompletedEventArgs
Public Class UploadFileCompletedEventArgs
Inherits AsyncCompletedEventArgs
Наследование
UploadFileCompletedEventArgsUploadFileCompletedEventArgsUploadFileCompletedEventArgsUploadFileCompletedEventArgs

Примеры

В следующем примере кода демонстрируется асинхронная отправка файла.The following code example demonstrates asynchronously uploading a file.

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

При завершении передачи вызывается следующий метод.The following method is called when the upload completes.

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

Комментарии

Экземпляры этого класса передаются в UploadFileCompletedEventHandler.Instances of this class are passed to the UploadFileCompletedEventHandler.

Свойства

Cancelled Cancelled Cancelled Cancelled

Возвращает значение, показывающее, была ли отменена асинхронная операция.Gets a value indicating whether an asynchronous operation has been canceled.

(Inherited from AsyncCompletedEventArgs)
Error Error Error Error

Возвращает значение, показывающее, какая ошибка произошла в течение асинхронной операции.Gets a value indicating which error occurred during an asynchronous operation.

(Inherited from AsyncCompletedEventArgs)
Result Result Result Result

Возвращает ответ сервера на операцию выгрузки данных, начатую посредством вызова метода UploadFileAsync.Gets the server reply to a data upload operation that is started by calling an UploadFileAsync method.

UserState UserState UserState UserState

Возвращает уникальный идентификатор для асинхронной задачи.Gets the unique identifier for the asynchronous task.

(Inherited from AsyncCompletedEventArgs)

Методы

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Определяет, равен ли заданный объект текущему объекту.Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Служит хэш-функцией по умолчанию.Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

Возвращает объект Type для текущего экземпляра.Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Создает неполную копию текущего объекта Object.Creates a shallow copy of the current Object.

(Inherited from Object)
RaiseExceptionIfNecessary() RaiseExceptionIfNecessary() RaiseExceptionIfNecessary() RaiseExceptionIfNecessary()

Вызывает предоставленное пользователем исключение в случае неудачного выполнения асинхронной операции.Raises a user-supplied exception if an asynchronous operation failed.

(Inherited from AsyncCompletedEventArgs)
ToString() ToString() ToString() ToString()

Возвращает строку, представляющую текущий объект.Returns a string that represents the current object.

(Inherited from Object)

Применяется к