Class System.Net.WebClient
Provides an easy-to-use interface for sending data to and receiving data from a resource identified by a URI. This class is obsolete.
Remarks
The WebClient class provides simplified access to HTTP, FTP, and file protocols. For new development, use the HttpClient class.
WebClient is obsolete and will be removed in a future version. The HttpClient class is the recommended alternative for all new development. It provides more flexibility and features, including support for asynchronous operations and custom headers.
Members
Properties
| Name | Description |
|---|---|
| BaseAddress | Gets or sets the base address of the URIs used for requests. |
| Credentials | Gets or sets the credentials used for authentication. |
| IsBusy | Gets a value indicating whether the WebClient is in the process of an asynchronous operation. |
| Proxy | Gets or sets the WebProxy object used to access the Internet. |
| QueryString | Gets or sets a collection of name/value pairs that are transmitted to the server. |
| UseDefaultCredentials | Gets or sets a value indicating whether to send the default credentials for authentication. |
Methods
| Name | Description |
|---|---|
| CancelAsync() | Cancels all pending asynchronous operations. |
| DownloadData(String address) | Downloads the resource with the specified URI as a String. |
| DownloadDataAsync(Uri address) | Starts an asynchronous request to download the resource with the specified URI. |
| DownloadFile(String address, String fileName) | Downloads the resource with the specified URI to a local file. |
| DownloadFileAsync(Uri address, String fileName) | Starts an asynchronous request to download the resource with the specified URI to a local file. |
| OpenRead(String address) | Opens a readable stream (following the URI) to the resource. |
| OpenReadAsync(Uri address) | Starts an asynchronous request to open a readable stream to the resource identified by the URI. |
| UploadData(String address, Byte[] data) | Uploads the specified data to the specified resource. |
| UploadDataAsync(Uri address, Byte[] data) | Starts an asynchronous request to upload the specified data to the specified resource. |
| UploadFile(String address, String fileName) | Uploads the specified local file to the specified resource. |
| UploadFileAsync(Uri address, String fileName) | Starts an asynchronous request to upload the specified local file to the specified resource. |
Events
| Name | Description |
|---|---|
| DownloadDataCompleted | Raised when an asynchronous data download operation completes. |
| DownloadFileCompleted | Raised when an asynchronous file download operation completes. |
| UploadDataCompleted | Raised when an asynchronous data upload operation completes. |
| UploadFileCompleted | Raised when an asynchronous file upload operation completes. |