WebClient.UploadFileCompleted Event


The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Occurs when an asynchronous file-upload operation completes.

Namespace:   System.Net
Assembly:  System (in System.dll)

Public Event UploadFileCompleted As UploadFileCompletedEventHandler

This event is raised each time an asynchronous file upload operation completes. Asynchronous file uploads are started by calling the UploadFileAsync methods.

The UploadFileCompletedEventHandler is the delegate for this event. The UploadFileCompletedEventArgs class provides the event handler with event data.

For more information about handling events, see NIB: Consuming Events.

The following code example demonstrates setting an event handler for this event.

'  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

.NET Framework
Available since 2.0
Return to top