WebClient WebClient WebClient WebClient Class

定义

提供用于将数据发送到由 URI 标识的资源及从这样的资源接收数据的常用方法。 Provides common methods for sending data to and receiving data from a resource identified by a URI.

public ref class WebClient : System::ComponentModel::Component
[System.Runtime.InteropServices.ComVisible(true)]
public class WebClient : System.ComponentModel.Component
type WebClient = class
    inherit Component
Public Class WebClient
Inherits Component
继承
属性

示例

下面的代码示例采用资源的 URI,检索它,并显示响应。The following code example takes the URI of a resource, retrieves it, and displays the response.

#using <System.dll>

using namespace System;
using namespace System::Net;
using namespace System::IO;
int main()
{
   array<String^>^args = Environment::GetCommandLineArgs();
   if ( args == nullptr || args->Length == 1 )
   {
      throw gcnew ApplicationException( "Specify the URI of the resource to retrieve." );
   }

   WebClient^ client = gcnew WebClient;
   
   // Add a user agent header in case the 
   // requested URI contains a query.
   client->Headers->Add( "user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)" );
   Stream^ data = client->OpenRead( args[ 1 ] );
   StreamReader^ reader = gcnew StreamReader( data );
   String^ s = reader->ReadToEnd();
   Console::WriteLine( s );
   data->Close();
   reader->Close();
}

using System;
using System.Net;
using System.IO;

public class Test
{
    public static void Main (string[] args)
    {
        if (args == null || args.Length == 0)
        {
            throw new ApplicationException ("Specify the URI of the resource to retrieve.");
        }
        WebClient client = new WebClient ();

        // Add a user agent header in case the 
        // requested URI contains a query.

        client.Headers.Add ("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");

        Stream data = client.OpenRead (args[0]);
        StreamReader reader = new StreamReader (data);
        string s = reader.ReadToEnd ();
        Console.WriteLine (s);
        data.Close ();
        reader.Close ();
    }
}
Imports System
Imports System.Net
Imports System.IO



Public Class Test
    
    Public Shared Sub Main(args() As String)
        If args Is Nothing OrElse args.Length = 0 Then
            Throw New ApplicationException("Specify the URI of the resource to retrieve.")
        End If
        Dim client As New WebClient()
        
        ' Add a user agent header in case the 
        ' requested URI contains a query.
        client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)")
        
        Dim data As Stream = client.OpenRead(args(0))
        Dim reader As New StreamReader(data)
        Dim s As String = reader.ReadToEnd()
        Console.WriteLine(s)
        data.Close()
        reader.Close()
    End Sub 'Main
End Class 'Test

注解

重要

我们不建议你使用WebClient类的新的开发。We don't recommend that you use the WebClient class for new development. 请改用System.Net.Http.HttpClient类。Instead, use the System.Net.Http.HttpClient class.

WebClient类提供了将数据发送到或从任何本地、 intranet 或由 URI 标识的 Internet 资源接收数据的常见方法。The WebClient class provides common methods for sending data to or receiving data from any local, intranet, or Internet resource identified by a URI.

WebClient类使用WebRequest类以提供对资源的访问。The WebClient class uses the WebRequest class to provide access to resources. WebClient 实例可以访问任何数据WebRequest后代注册WebRequest.RegisterPrefix方法。WebClient instances can access data with any WebRequest descendant registered with the WebRequest.RegisterPrefix method.

备注

默认情况下,.NET Framework 支持开头的 Uri http:https:ftp:,和file:方案标识符。By default, the .NET Framework supports URIs that begin with http:, https:, ftp:, and file: scheme identifiers.

下表描述了WebClient方法将数据上传到的资源。The following table describes WebClient methods for uploading data to a resource.

方法Method 描述Description
OpenWrite 检索Stream用于将数据发送到的资源。Retrieves a Stream used to send data to the resource.
OpenWriteAsync 检索Stream用于将数据发送到资源,而不会阻止调用线程。Retrieves a Stream used to send data to the resource, without blocking the calling thread.
UploadData 向资源发送的字节数组,并返回Byte数组,其中包含的任何响应。Sends a byte array to the resource and returns a Byte array containing any response.
UploadDataAsync 将发送Byte阵列分区到的资源,而不会阻止调用线程。Sends a Byte array to the resource, without blocking the calling thread.
UploadFile 将本地文件发送到资源,并返回Byte数组,其中包含的任何响应。Sends a local file to the resource and returns a Byte array containing any response.
UploadFileAsync 将本地文件发送到该资源,而不会阻止调用线程。Sends a local file to the resource, without blocking the calling thread.
UploadValues 将发送NameValueCollection资源,并返回到Byte数组,其中包含的任何响应。Sends a NameValueCollection to the resource and returns a Byte array containing any response.
UploadValuesAsync 将发送NameValueCollection资源,并返回到Byte数组,包含任何响应,而不会阻止调用线程。Sends a NameValueCollection to the resource and returns a Byte array containing any response, without blocking the calling thread.
UploadString 将发送String的资源,而不会阻止调用线程。Sends a String to the resource, without blocking the calling thread.
UploadStringAsync 将发送String的资源,而不会阻止调用线程。Sends a String to the resource, without blocking the calling thread.

下表描述了WebClient从资源下载数据的方法。The following table describes WebClient methods for downloading data from a resource.

方法Method 描述Description
OpenRead 从作为资源返回数据StreamReturns the data from a resource as a Stream.
OpenReadAsync 返回从资源,而不会阻止调用线程的数据。Returns the data from a resource, without blocking the calling thread.
DownloadData 从资源下载数据,并返回Byte数组。Downloads data from a resource and returns a Byte array.
DownloadDataAsync 从资源下载数据,并返回Byte数组,而不会阻止调用线程。Downloads data from a resource and returns a Byte array, without blocking the calling thread.
DownloadFile 将数据从资源下载到本地文件。Downloads data from a resource to a local file.
DownloadFileAsync 数据从资源下载到本地文件,而不会阻止调用线程。Downloads data from a resource to a local file, without blocking the calling thread.
DownloadString 下载String资源,并返回从StringDownloads a String from a resource and returns a String.
DownloadStringAsync 下载String从资源,而不会阻止调用线程。Downloads a String from a resource, without blocking the calling thread.

可以使用CancelAsync方法来取消异步操作尚未完成的。You can use the CancelAsync method to cancel asynchronous operations that have not completed.

一个WebClient实例不会发送默认情况下的可选 HTTP 标头。A WebClient instance does not send optional HTTP headers by default. 如果您的请求需要的可选标头,则必须添加到标头Headers集合。If your request requires an optional header, you must add the header to the Headers collection. 例如,若要保留在响应中的查询,必须添加的用户代理标头。For example, to retain queries in the response, you must add a user-agent header. 此外,服务器可能会返回 500 (内部服务器错误),如果缺少用户代理标头。Also, servers may return 500 (Internal Server Error) if the user agent header is missing.

AllowAutoRedirect 设置为trueWebClient实例。AllowAutoRedirect is set to true in WebClient instances.

继承者说明

派生的类应调用基类实现WebClient以确保派生的类按预期方式工作。 Derived classes should call the base class implementation of WebClient to ensure the derived class works as expected.

构造函数

WebClient() WebClient() WebClient() WebClient()

初始化 WebClient 类的新实例。 Initializes a new instance of the WebClient class.

属性

AllowReadStreamBuffering AllowReadStreamBuffering AllowReadStreamBuffering AllowReadStreamBuffering

获取或设置一个值,该值指示是否对从某一 WebClient 实例的 Internet 资源读取的数据进行缓冲处理。 Gets or sets a value that indicates whether to buffer the data read from the Internet resource for a WebClient instance.

AllowWriteStreamBuffering AllowWriteStreamBuffering AllowWriteStreamBuffering AllowWriteStreamBuffering

获取或设置一个值,该值指示是否对写入到 WebClient 实例的 Internet 资源的数据进行缓冲处理。 Gets or sets a value that indicates whether to buffer the data written to the Internet resource for a WebClient instance.

BaseAddress BaseAddress BaseAddress BaseAddress

获取或设置 WebClient 发出请求的基 URI。 Gets or sets the base URI for requests made by a WebClient.

CachePolicy CachePolicy CachePolicy CachePolicy

对于此 WebClient 实例使用 WebRequest 对象获得的任何资源,获取或设置应用程序的缓存策略。 Gets or sets the application's cache policy for any resources obtained by this WebClient instance using WebRequest objects.

CanRaiseEvents CanRaiseEvents CanRaiseEvents CanRaiseEvents

获取一个指示组件是否可以引发事件的值。 Gets a value indicating whether the component can raise an event.

(Inherited from Component)
Container Container Container Container

获取 IContainer,它包含 Component Gets the IContainer that contains the Component.

(Inherited from Component)
Credentials Credentials Credentials Credentials

获取或设置发送到主机并用于对请求进行身份验证的网络凭据。 Gets or sets the network credentials that are sent to the host and used to authenticate the request.

DesignMode DesignMode DesignMode DesignMode

获取一个值,用以指示 Component 当前是否处于设计模式。 Gets a value that indicates whether the Component is currently in design mode.

(Inherited from Component)
Encoding Encoding Encoding Encoding

获取和设置用于上载和下载字符串的 Encoding Gets and sets the Encoding used to upload and download strings.

Events Events Events Events

获取附加到此 Component 的事件处理程序的列表。 Gets the list of event handlers that are attached to this Component.

(Inherited from Component)
Headers Headers Headers Headers

获取或设置与请求关联的标头名称/值对集合。 Gets or sets a collection of header name/value pairs associated with the request.

IsBusy IsBusy IsBusy IsBusy

了解是否存在进行中的 Web 请求。 Gets whether a Web request is in progress.

Proxy Proxy Proxy Proxy

获取或设置此 WebClient 对象使用的代理。 Gets or sets the proxy used by this WebClient object.

QueryString QueryString QueryString QueryString

获取或设置与请求关联的查询名称/值对集合。 Gets or sets a collection of query name/value pairs associated with the request.

ResponseHeaders ResponseHeaders ResponseHeaders ResponseHeaders

获取与响应关联的标头名称/值对集合。 Gets a collection of header name/value pairs associated with the response.

Site Site Site Site

获取或设置 ComponentISite Gets or sets the ISite of the Component.

(Inherited from Component)
UseDefaultCredentials UseDefaultCredentials UseDefaultCredentials UseDefaultCredentials

获取或设置 Boolean 值,该值控制 DefaultCredentials 是否随请求一起发送。 Gets or sets a Boolean value that controls whether the DefaultCredentials are sent with requests.

方法

CancelAsync() CancelAsync() CancelAsync() CancelAsync()

取消一个挂起的异步操作。 Cancels a pending asynchronous operation.

CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type)

创建一个对象,该对象包含生成用于与远程对象进行通信的代理所需的全部相关信息。 Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.

(Inherited from MarshalByRefObject)
Dispose() Dispose() Dispose() Dispose()

释放由 Component 使用的所有资源。 Releases all resources used by the Component.

(Inherited from Component)
Dispose(Boolean) Dispose(Boolean) Dispose(Boolean) Dispose(Boolean)

释放由 Component 占用的非托管资源,还可以另外再释放托管资源。 Releases the unmanaged resources used by the Component and optionally releases the managed resources.

(Inherited from Component)
DownloadData(String) DownloadData(String) DownloadData(String) DownloadData(String)

从指定 URI 下载资源作为 Byte 数组。 Downloads the resource as a Byte array from the URI specified.

DownloadData(Uri) DownloadData(Uri) DownloadData(Uri) DownloadData(Uri)

从指定 URI 下载资源作为 Byte 数组。 Downloads the resource as a Byte array from the URI specified.

DownloadDataAsync(Uri) DownloadDataAsync(Uri) DownloadDataAsync(Uri) DownloadDataAsync(Uri)

从指定 URI 中将资源作为 Byte 数组下载以作为异步操作。 Downloads the resource as a Byte array from the URI specified as an asynchronous operation.

DownloadDataAsync(Uri, Object) DownloadDataAsync(Uri, Object) DownloadDataAsync(Uri, Object) DownloadDataAsync(Uri, Object)

从指定 URI 中将资源作为 Byte 数组下载以作为异步操作。 Downloads the resource as a Byte array from the URI specified as an asynchronous operation.

DownloadDataTaskAsync(String) DownloadDataTaskAsync(String) DownloadDataTaskAsync(String) DownloadDataTaskAsync(String)

使用任务对象从指定 URI 中将资源作为 Byte 数组下载以作为异步操作。 Downloads the resource as a Byte array from the URI specified as an asynchronous operation using a task object.

DownloadDataTaskAsync(Uri) DownloadDataTaskAsync(Uri) DownloadDataTaskAsync(Uri) DownloadDataTaskAsync(Uri)

使用任务对象从指定 URI 中将资源作为 Byte 数组下载以作为异步操作。 Downloads the resource as a Byte array from the URI specified as an asynchronous operation using a task object.

DownloadFile(String, String) DownloadFile(String, String) DownloadFile(String, String) DownloadFile(String, String)

将具有指定 URI 的资源下载到本地文件。 Downloads the resource with the specified URI to a local file.

DownloadFile(Uri, String) DownloadFile(Uri, String) DownloadFile(Uri, String) DownloadFile(Uri, String)

将具有指定 URI 的资源下载到本地文件。 Downloads the resource with the specified URI to a local file.

DownloadFileAsync(Uri, String) DownloadFileAsync(Uri, String) DownloadFileAsync(Uri, String) DownloadFileAsync(Uri, String)

将具有指定 URI 的资源下载到本地文件。 Downloads, to a local file, the resource with the specified URI. 此方法不会阻止调用线程。 This method does not block the calling thread.

DownloadFileAsync(Uri, String, Object) DownloadFileAsync(Uri, String, Object) DownloadFileAsync(Uri, String, Object) DownloadFileAsync(Uri, String, Object)

将具有指定 URI 的资源下载到本地文件。 Downloads, to a local file, the resource with the specified URI. 此方法不会阻止调用线程。 This method does not block the calling thread.

DownloadFileTaskAsync(String, String) DownloadFileTaskAsync(String, String) DownloadFileTaskAsync(String, String) DownloadFileTaskAsync(String, String)

使用任务对象将指定资源下载到本地文件以作为异步操作。 Downloads the specified resource to a local file as an asynchronous operation using a task object.

DownloadFileTaskAsync(Uri, String) DownloadFileTaskAsync(Uri, String) DownloadFileTaskAsync(Uri, String) DownloadFileTaskAsync(Uri, String)

使用任务对象将指定资源下载到本地文件以作为异步操作。 Downloads the specified resource to a local file as an asynchronous operation using a task object.

DownloadString(String) DownloadString(String) DownloadString(String) DownloadString(String)

String 形式下载请求的资源。 Downloads the requested resource as a String. 以包含 URI 的 String 的形式指定要下载的资源。 The resource to download is specified as a String containing the URI.

DownloadString(Uri) DownloadString(Uri) DownloadString(Uri) DownloadString(Uri)

String 形式下载请求的资源。 Downloads the requested resource as a String. Uri 形式指定要下载的资源。 The resource to download is specified as a Uri.

DownloadStringAsync(Uri) DownloadStringAsync(Uri) DownloadStringAsync(Uri) DownloadStringAsync(Uri)

下载以 Uri 形式指定的资源。 Downloads the resource specified as a Uri. 此方法不会阻止调用线程。 This method does not block the calling thread.

DownloadStringAsync(Uri, Object) DownloadStringAsync(Uri, Object) DownloadStringAsync(Uri, Object) DownloadStringAsync(Uri, Object)

将指定的字符串下载到指定的资源。 Downloads the specified string to the specified resource. 此方法不会阻止调用线程。 This method does not block the calling thread.

DownloadStringTaskAsync(String) DownloadStringTaskAsync(String) DownloadStringTaskAsync(String) DownloadStringTaskAsync(String)

使用任务对象从指定 URI 中将资源作为 String 下载以作为异步操作。 Downloads the resource as a String from the URI specified as an asynchronous operation using a task object.

DownloadStringTaskAsync(Uri) DownloadStringTaskAsync(Uri) DownloadStringTaskAsync(Uri) DownloadStringTaskAsync(Uri)

使用任务对象从指定 URI 中将资源作为 String 下载以作为异步操作。 Downloads the resource as a String from the URI specified as an asynchronous operation using a task object.

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)
GetLifetimeService() GetLifetimeService() GetLifetimeService() GetLifetimeService()

检索控制此实例的生存期策略的当前生存期服务对象。 Retrieves the current lifetime service object that controls the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
GetService(Type) GetService(Type) GetService(Type) GetService(Type)

返回一个对象,该对象表示由 Component 或它的 Container 提供的服务。 Returns an object that represents a service provided by the Component or by its Container.

(Inherited from Component)
GetType() GetType() GetType() GetType()

获取当前实例的 Type Gets the Type of the current instance.

(Inherited from Object)
GetWebRequest(Uri) GetWebRequest(Uri) GetWebRequest(Uri) GetWebRequest(Uri)

为指定资源返回一个 WebRequest 对象。 Returns a WebRequest object for the specified resource.

GetWebResponse(WebRequest) GetWebResponse(WebRequest) GetWebResponse(WebRequest) GetWebResponse(WebRequest)

返回指定 WebResponseWebRequest Returns the WebResponse for the specified WebRequest.

GetWebResponse(WebRequest, IAsyncResult) GetWebResponse(WebRequest, IAsyncResult) GetWebResponse(WebRequest, IAsyncResult) GetWebResponse(WebRequest, IAsyncResult)

使用指定的 WebResponse 获取对指定 WebRequestIAsyncResult Returns the WebResponse for the specified WebRequest using the specified IAsyncResult.

InitializeLifetimeService() InitializeLifetimeService() InitializeLifetimeService() InitializeLifetimeService()

获取生存期服务对象来控制此实例的生存期策略。 Obtains a lifetime service object to control the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

创建当前 Object 的浅表副本。 Creates a shallow copy of the current Object.

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

创建当前 MarshalByRefObject 对象的浅表副本。 Creates a shallow copy of the current MarshalByRefObject object.

(Inherited from MarshalByRefObject)
OnDownloadDataCompleted(DownloadDataCompletedEventArgs) OnDownloadDataCompleted(DownloadDataCompletedEventArgs) OnDownloadDataCompleted(DownloadDataCompletedEventArgs) OnDownloadDataCompleted(DownloadDataCompletedEventArgs)

引发 DownloadDataCompleted 事件。 Raises the DownloadDataCompleted event.

OnDownloadFileCompleted(AsyncCompletedEventArgs) OnDownloadFileCompleted(AsyncCompletedEventArgs) OnDownloadFileCompleted(AsyncCompletedEventArgs) OnDownloadFileCompleted(AsyncCompletedEventArgs)

引发 DownloadFileCompleted 事件。 Raises the DownloadFileCompleted event.

OnDownloadProgressChanged(DownloadProgressChangedEventArgs) OnDownloadProgressChanged(DownloadProgressChangedEventArgs) OnDownloadProgressChanged(DownloadProgressChangedEventArgs) OnDownloadProgressChanged(DownloadProgressChangedEventArgs)

引发 DownloadProgressChanged 事件。 Raises the DownloadProgressChanged event.

OnDownloadStringCompleted(DownloadStringCompletedEventArgs) OnDownloadStringCompleted(DownloadStringCompletedEventArgs) OnDownloadStringCompleted(DownloadStringCompletedEventArgs) OnDownloadStringCompleted(DownloadStringCompletedEventArgs)

引发 DownloadStringCompleted 事件。 Raises the DownloadStringCompleted event.

OnOpenReadCompleted(OpenReadCompletedEventArgs) OnOpenReadCompleted(OpenReadCompletedEventArgs) OnOpenReadCompleted(OpenReadCompletedEventArgs) OnOpenReadCompleted(OpenReadCompletedEventArgs)

引发 OpenReadCompleted 事件。 Raises the OpenReadCompleted event.

OnOpenWriteCompleted(OpenWriteCompletedEventArgs) OnOpenWriteCompleted(OpenWriteCompletedEventArgs) OnOpenWriteCompleted(OpenWriteCompletedEventArgs) OnOpenWriteCompleted(OpenWriteCompletedEventArgs)

引发 OpenWriteCompleted 事件。 Raises the OpenWriteCompleted event.

OnUploadDataCompleted(UploadDataCompletedEventArgs) OnUploadDataCompleted(UploadDataCompletedEventArgs) OnUploadDataCompleted(UploadDataCompletedEventArgs) OnUploadDataCompleted(UploadDataCompletedEventArgs)

引发 UploadDataCompleted 事件。 Raises the UploadDataCompleted event.

OnUploadFileCompleted(UploadFileCompletedEventArgs) OnUploadFileCompleted(UploadFileCompletedEventArgs) OnUploadFileCompleted(UploadFileCompletedEventArgs) OnUploadFileCompleted(UploadFileCompletedEventArgs)

引发 UploadFileCompleted 事件。 Raises the UploadFileCompleted event.

OnUploadProgressChanged(UploadProgressChangedEventArgs) OnUploadProgressChanged(UploadProgressChangedEventArgs) OnUploadProgressChanged(UploadProgressChangedEventArgs) OnUploadProgressChanged(UploadProgressChangedEventArgs)

引发 UploadProgressChanged 事件。 Raises the UploadProgressChanged event.

OnUploadStringCompleted(UploadStringCompletedEventArgs) OnUploadStringCompleted(UploadStringCompletedEventArgs) OnUploadStringCompleted(UploadStringCompletedEventArgs) OnUploadStringCompleted(UploadStringCompletedEventArgs)

引发 UploadStringCompleted 事件。 Raises the UploadStringCompleted event.

OnUploadValuesCompleted(UploadValuesCompletedEventArgs) OnUploadValuesCompleted(UploadValuesCompletedEventArgs) OnUploadValuesCompleted(UploadValuesCompletedEventArgs) OnUploadValuesCompleted(UploadValuesCompletedEventArgs)

引发 UploadValuesCompleted 事件。 Raises the UploadValuesCompleted event.

OnWriteStreamClosed(WriteStreamClosedEventArgs) OnWriteStreamClosed(WriteStreamClosedEventArgs) OnWriteStreamClosed(WriteStreamClosedEventArgs) OnWriteStreamClosed(WriteStreamClosedEventArgs)

引发 WriteStreamClosed 事件。 Raises the WriteStreamClosed event.

OpenRead(String) OpenRead(String) OpenRead(String) OpenRead(String)

为从具有 String 指定的 URI 的资源下载的数据打开一个可读的流。 Opens a readable stream for the data downloaded from a resource with the URI specified as a String.

OpenRead(Uri) OpenRead(Uri) OpenRead(Uri) OpenRead(Uri)

为从具有 Uri 指定的 URI 的资源下载的数据打开一个可读的流 Opens a readable stream for the data downloaded from a resource with the URI specified as a Uri

OpenReadAsync(Uri) OpenReadAsync(Uri) OpenReadAsync(Uri) OpenReadAsync(Uri)

打开包含指定资源的可读流。 Opens a readable stream containing the specified resource. 此方法不会阻止调用线程。 This method does not block the calling thread.

OpenReadAsync(Uri, Object) OpenReadAsync(Uri, Object) OpenReadAsync(Uri, Object) OpenReadAsync(Uri, Object)

打开包含指定资源的可读流。 Opens a readable stream containing the specified resource. 此方法不会阻止调用线程。 This method does not block the calling thread.

OpenReadTaskAsync(String) OpenReadTaskAsync(String) OpenReadTaskAsync(String) OpenReadTaskAsync(String)

使用任务对象打开包含指定资源的可读流以作为异步操作。 Opens a readable stream containing the specified resource as an asynchronous operation using a task object.

OpenReadTaskAsync(Uri) OpenReadTaskAsync(Uri) OpenReadTaskAsync(Uri) OpenReadTaskAsync(Uri)

使用任务对象打开包含指定资源的可读流以作为异步操作。 Opens a readable stream containing the specified resource as an asynchronous operation using a task object.

OpenWrite(String) OpenWrite(String) OpenWrite(String) OpenWrite(String)

打开一个流以将数据写入指定的资源。 Opens a stream for writing data to the specified resource.

OpenWrite(String, String) OpenWrite(String, String) OpenWrite(String, String) OpenWrite(String, String)

打开一个流以使用指定的方法向指定的资源写入数据。 Opens a stream for writing data to the specified resource, using the specified method.

OpenWrite(Uri) OpenWrite(Uri) OpenWrite(Uri) OpenWrite(Uri)

打开一个流以将数据写入指定的资源。 Opens a stream for writing data to the specified resource.

OpenWrite(Uri, String) OpenWrite(Uri, String) OpenWrite(Uri, String) OpenWrite(Uri, String)

打开一个流以使用指定的方法将数据写入指定的资源。 Opens a stream for writing data to the specified resource, by using the specified method.

OpenWriteAsync(Uri) OpenWriteAsync(Uri) OpenWriteAsync(Uri) OpenWriteAsync(Uri)

打开一个流以将数据写入指定的资源。 Opens a stream for writing data to the specified resource. 此方法不会阻止调用线程。 This method does not block the calling thread.

OpenWriteAsync(Uri, String) OpenWriteAsync(Uri, String) OpenWriteAsync(Uri, String) OpenWriteAsync(Uri, String)

打开一个流以将数据写入指定的资源。 Opens a stream for writing data to the specified resource. 此方法不会阻止调用线程。 This method does not block the calling thread.

OpenWriteAsync(Uri, String, Object) OpenWriteAsync(Uri, String, Object) OpenWriteAsync(Uri, String, Object) OpenWriteAsync(Uri, String, Object)

打开一个流以使用指定的方法向指定的资源写入数据。 Opens a stream for writing data to the specified resource, using the specified method. 此方法不会阻止调用线程。 This method does not block the calling thread.

OpenWriteTaskAsync(String) OpenWriteTaskAsync(String) OpenWriteTaskAsync(String) OpenWriteTaskAsync(String)

使用任务对象打开用于将数据写入指定资源的流以作为异步操作。 Opens a stream for writing data to the specified resource as an asynchronous operation using a task object.

OpenWriteTaskAsync(String, String) OpenWriteTaskAsync(String, String) OpenWriteTaskAsync(String, String) OpenWriteTaskAsync(String, String)

使用任务对象打开用于将数据写入指定资源的流以作为异步操作。 Opens a stream for writing data to the specified resource as an asynchronous operation using a task object.

OpenWriteTaskAsync(Uri) OpenWriteTaskAsync(Uri) OpenWriteTaskAsync(Uri) OpenWriteTaskAsync(Uri)

使用任务对象打开用于将数据写入指定资源的流以作为异步操作。 Opens a stream for writing data to the specified resource as an asynchronous operation using a task object.

OpenWriteTaskAsync(Uri, String) OpenWriteTaskAsync(Uri, String) OpenWriteTaskAsync(Uri, String) OpenWriteTaskAsync(Uri, String)

使用任务对象打开用于将数据写入指定资源的流以作为异步操作。 Opens a stream for writing data to the specified resource as an asynchronous operation using a task object.

ToString() ToString() ToString() ToString()

返回包含 Component 的名称的 String(如果有)。 Returns a String containing the name of the Component, if any. 不应重写此方法。 This method should not be overridden.

(Inherited from Component)
UploadData(String, Byte[]) UploadData(String, Byte[]) UploadData(String, Byte[]) UploadData(String, Byte[])

将数据缓冲区上载到由 URI 标识的资源。 Uploads a data buffer to a resource identified by a URI.

UploadData(String, String, Byte[]) UploadData(String, String, Byte[]) UploadData(String, String, Byte[]) UploadData(String, String, Byte[])

使用指定的方法将数据缓冲区上载到指定资源。 Uploads a data buffer to the specified resource, using the specified method.

UploadData(Uri, Byte[]) UploadData(Uri, Byte[]) UploadData(Uri, Byte[]) UploadData(Uri, Byte[])

将数据缓冲区上载到由 URI 标识的资源。 Uploads a data buffer to a resource identified by a URI.

UploadData(Uri, String, Byte[]) UploadData(Uri, String, Byte[]) UploadData(Uri, String, Byte[]) UploadData(Uri, String, Byte[])

使用指定的方法将数据缓冲区上载到指定资源。 Uploads a data buffer to the specified resource, using the specified method.

UploadDataAsync(Uri, Byte[]) UploadDataAsync(Uri, Byte[]) UploadDataAsync(Uri, Byte[]) UploadDataAsync(Uri, Byte[])

使用 POST 方法将数据缓冲区上载到由 URI 标识的资源。 Uploads a data buffer to a resource identified by a URI, using the POST method. 此方法不会阻止调用线程。 This method does not block the calling thread.

UploadDataAsync(Uri, String, Byte[]) UploadDataAsync(Uri, String, Byte[]) UploadDataAsync(Uri, String, Byte[]) UploadDataAsync(Uri, String, Byte[])

使用指定的方法将数据缓冲区上载到由 URI 标识的资源。 Uploads a data buffer to a resource identified by a URI, using the specified method. 此方法不会阻止调用线程。 This method does not block the calling thread.

UploadDataAsync(Uri, String, Byte[], Object) UploadDataAsync(Uri, String, Byte[], Object) UploadDataAsync(Uri, String, Byte[], Object) UploadDataAsync(Uri, String, Byte[], Object)

使用指定的方法和标识标记将数据缓冲区上载到由 URI 标识的资源。 Uploads a data buffer to a resource identified by a URI, using the specified method and identifying token.

UploadDataTaskAsync(String, Byte[]) UploadDataTaskAsync(String, Byte[]) UploadDataTaskAsync(String, Byte[]) UploadDataTaskAsync(String, Byte[])

使用任务对象将包含 Byte 数组的数据缓冲区上载到指定 URI 以作为异步操作。 Uploads a data buffer that contains a Byte array to the URI specified as an asynchronous operation using a task object.

UploadDataTaskAsync(String, String, Byte[]) UploadDataTaskAsync(String, String, Byte[]) UploadDataTaskAsync(String, String, Byte[]) UploadDataTaskAsync(String, String, Byte[])

使用任务对象将包含 Byte 数组的数据缓冲区上载到指定 URI 以作为异步操作。 Uploads a data buffer that contains a Byte array to the URI specified as an asynchronous operation using a task object.

UploadDataTaskAsync(Uri, Byte[]) UploadDataTaskAsync(Uri, Byte[]) UploadDataTaskAsync(Uri, Byte[]) UploadDataTaskAsync(Uri, Byte[])

使用任务对象将包含 Byte 数组的数据缓冲区上载到指定 URI 以作为异步操作。 Uploads a data buffer that contains a Byte array to the URI specified as an asynchronous operation using a task object.

UploadDataTaskAsync(Uri, String, Byte[]) UploadDataTaskAsync(Uri, String, Byte[]) UploadDataTaskAsync(Uri, String, Byte[]) UploadDataTaskAsync(Uri, String, Byte[])

使用任务对象将包含 Byte 数组的数据缓冲区上载到指定 URI 以作为异步操作。 Uploads a data buffer that contains a Byte array to the URI specified as an asynchronous operation using a task object.

UploadFile(String, String) UploadFile(String, String) UploadFile(String, String) UploadFile(String, String)

将指定的本地文件上载到具有指定 URI 的资源。 Uploads the specified local file to a resource with the specified URI.

UploadFile(String, String, String) UploadFile(String, String, String) UploadFile(String, String, String) UploadFile(String, String, String)

使用指定的方法将指定的本地文件上载到指定的资源。 Uploads the specified local file to the specified resource, using the specified method.

UploadFile(Uri, String) UploadFile(Uri, String) UploadFile(Uri, String) UploadFile(Uri, String)

将指定的本地文件上载到具有指定 URI 的资源。 Uploads the specified local file to a resource with the specified URI.

UploadFile(Uri, String, String) UploadFile(Uri, String, String) UploadFile(Uri, String, String) UploadFile(Uri, String, String)

使用指定的方法将指定的本地文件上载到指定的资源。 Uploads the specified local file to the specified resource, using the specified method.

UploadFileAsync(Uri, String) UploadFileAsync(Uri, String) UploadFileAsync(Uri, String) UploadFileAsync(Uri, String)

使用 POST 方法将指定的本地文件上载到指定的资源。 Uploads the specified local file to the specified resource, using the POST method. 此方法不会阻止调用线程。 This method does not block the calling thread.

UploadFileAsync(Uri, String, String) UploadFileAsync(Uri, String, String) UploadFileAsync(Uri, String, String) UploadFileAsync(Uri, String, String)

使用 POST 方法将指定的本地文件上载到指定的资源。 Uploads the specified local file to the specified resource, using the POST method. 此方法不会阻止调用线程。 This method does not block the calling thread.

UploadFileAsync(Uri, String, String, Object) UploadFileAsync(Uri, String, String, Object) UploadFileAsync(Uri, String, String, Object) UploadFileAsync(Uri, String, String, Object)

使用 POST 方法将指定的本地文件上载到指定的资源。 Uploads the specified local file to the specified resource, using the POST method. 此方法不会阻止调用线程。 This method does not block the calling thread.

UploadFileTaskAsync(String, String) UploadFileTaskAsync(String, String) UploadFileTaskAsync(String, String) UploadFileTaskAsync(String, String)

使用任务对象将指定本地文件上载到资源以作为异步操作。 Uploads the specified local file to a resource as an asynchronous operation using a task object.

UploadFileTaskAsync(String, String, String) UploadFileTaskAsync(String, String, String) UploadFileTaskAsync(String, String, String) UploadFileTaskAsync(String, String, String)

使用任务对象将指定本地文件上载到资源以作为异步操作。 Uploads the specified local file to a resource as an asynchronous operation using a task object.

UploadFileTaskAsync(Uri, String) UploadFileTaskAsync(Uri, String) UploadFileTaskAsync(Uri, String) UploadFileTaskAsync(Uri, String)

使用任务对象将指定本地文件上载到资源以作为异步操作。 Uploads the specified local file to a resource as an asynchronous operation using a task object.

UploadFileTaskAsync(Uri, String, String) UploadFileTaskAsync(Uri, String, String) UploadFileTaskAsync(Uri, String, String) UploadFileTaskAsync(Uri, String, String)

使用任务对象将指定本地文件上载到资源以作为异步操作。 Uploads the specified local file to a resource as an asynchronous operation using a task object.

UploadString(String, String) UploadString(String, String) UploadString(String, String) UploadString(String, String)

使用 POST 方法将指定的字符串上载到指定的资源。 Uploads the specified string to the specified resource, using the POST method.

UploadString(String, String, String) UploadString(String, String, String) UploadString(String, String, String) UploadString(String, String, String)

使用指定的方法将指定的字符串上载到指定的资源。 Uploads the specified string to the specified resource, using the specified method.

UploadString(Uri, String) UploadString(Uri, String) UploadString(Uri, String) UploadString(Uri, String)

使用 POST 方法将指定的字符串上载到指定的资源。 Uploads the specified string to the specified resource, using the POST method.

UploadString(Uri, String, String) UploadString(Uri, String, String) UploadString(Uri, String, String) UploadString(Uri, String, String)

使用指定的方法将指定的字符串上载到指定的资源。 Uploads the specified string to the specified resource, using the specified method.

UploadStringAsync(Uri, String) UploadStringAsync(Uri, String) UploadStringAsync(Uri, String) UploadStringAsync(Uri, String)

将指定的字符串上载到指定的资源。 Uploads the specified string to the specified resource. 此方法不会阻止调用线程。 This method does not block the calling thread.

UploadStringAsync(Uri, String, String) UploadStringAsync(Uri, String, String) UploadStringAsync(Uri, String, String) UploadStringAsync(Uri, String, String)

将指定的字符串上载到指定的资源。 Uploads the specified string to the specified resource. 此方法不会阻止调用线程。 This method does not block the calling thread.

UploadStringAsync(Uri, String, String, Object) UploadStringAsync(Uri, String, String, Object) UploadStringAsync(Uri, String, String, Object) UploadStringAsync(Uri, String, String, Object)

将指定的字符串上载到指定的资源。 Uploads the specified string to the specified resource. 此方法不会阻止调用线程。 This method does not block the calling thread.

UploadStringTaskAsync(String, String) UploadStringTaskAsync(String, String) UploadStringTaskAsync(String, String) UploadStringTaskAsync(String, String)

使用任务对象将指定字符串上载到指定资源以作为异步操作。 Uploads the specified string to the specified resource as an asynchronous operation using a task object.

UploadStringTaskAsync(String, String, String) UploadStringTaskAsync(String, String, String) UploadStringTaskAsync(String, String, String) UploadStringTaskAsync(String, String, String)

使用任务对象将指定字符串上载到指定资源以作为异步操作。 Uploads the specified string to the specified resource as an asynchronous operation using a task object.

UploadStringTaskAsync(Uri, String) UploadStringTaskAsync(Uri, String) UploadStringTaskAsync(Uri, String) UploadStringTaskAsync(Uri, String)

使用任务对象将指定字符串上载到指定资源以作为异步操作。 Uploads the specified string to the specified resource as an asynchronous operation using a task object.

UploadStringTaskAsync(Uri, String, String) UploadStringTaskAsync(Uri, String, String) UploadStringTaskAsync(Uri, String, String) UploadStringTaskAsync(Uri, String, String)

使用任务对象将指定字符串上载到指定资源以作为异步操作。 Uploads the specified string to the specified resource as an asynchronous operation using a task object.

UploadValues(String, NameValueCollection) UploadValues(String, NameValueCollection) UploadValues(String, NameValueCollection) UploadValues(String, NameValueCollection)

将指定的名称/值集合上载到指定的 URI 所标识的资源。 Uploads the specified name/value collection to the resource identified by the specified URI.

UploadValues(String, String, NameValueCollection) UploadValues(String, String, NameValueCollection) UploadValues(String, String, NameValueCollection) UploadValues(String, String, NameValueCollection)

使用指定的方法将指定的名称/值集合上载到指定的 URI 所标识的资源。 Uploads the specified name/value collection to the resource identified by the specified URI, using the specified method.

UploadValues(Uri, NameValueCollection) UploadValues(Uri, NameValueCollection) UploadValues(Uri, NameValueCollection) UploadValues(Uri, NameValueCollection)

将指定的名称/值集合上载到指定的 URI 所标识的资源。 Uploads the specified name/value collection to the resource identified by the specified URI.

UploadValues(Uri, String, NameValueCollection) UploadValues(Uri, String, NameValueCollection) UploadValues(Uri, String, NameValueCollection) UploadValues(Uri, String, NameValueCollection)

使用指定的方法将指定的名称/值集合上载到指定的 URI 所标识的资源。 Uploads the specified name/value collection to the resource identified by the specified URI, using the specified method.

UploadValuesAsync(Uri, NameValueCollection) UploadValuesAsync(Uri, NameValueCollection) UploadValuesAsync(Uri, NameValueCollection) UploadValuesAsync(Uri, NameValueCollection)

将指定的名称/值集合中的数据上载到由指定的 URI 标识的资源。 Uploads the data in the specified name/value collection to the resource identified by the specified URI. 此方法不会阻止调用线程。 This method does not block the calling thread.

UploadValuesAsync(Uri, String, NameValueCollection) UploadValuesAsync(Uri, String, NameValueCollection) UploadValuesAsync(Uri, String, NameValueCollection) UploadValuesAsync(Uri, String, NameValueCollection)

使用指定的方法将指定的名称/值集合中的数据上载到由指定的 URI 标识的资源。 Uploads the data in the specified name/value collection to the resource identified by the specified URI, using the specified method. 此方法不会阻止调用线程。 This method does not block the calling thread.

UploadValuesAsync(Uri, String, NameValueCollection, Object) UploadValuesAsync(Uri, String, NameValueCollection, Object) UploadValuesAsync(Uri, String, NameValueCollection, Object) UploadValuesAsync(Uri, String, NameValueCollection, Object)

使用指定的方法将指定的名称/值集合中的数据上载到由指定的 URI 标识的资源。 Uploads the data in the specified name/value collection to the resource identified by the specified URI, using the specified method. 此方法不会阻止调用线程,并允许调用方将对象传递给操作完成时所调用的方法。 This method does not block the calling thread, and allows the caller to pass an object to the method that is invoked when the operation completes.

UploadValuesTaskAsync(String, NameValueCollection) UploadValuesTaskAsync(String, NameValueCollection) UploadValuesTaskAsync(String, NameValueCollection) UploadValuesTaskAsync(String, NameValueCollection)

使用任务对象将指定的名称/值集合上载到由指定 URI 标识的资源以作为异步操作。 Uploads the specified name/value collection to the resource identified by the specified URI as an asynchronous operation using a task object.

UploadValuesTaskAsync(String, String, NameValueCollection) UploadValuesTaskAsync(String, String, NameValueCollection) UploadValuesTaskAsync(String, String, NameValueCollection) UploadValuesTaskAsync(String, String, NameValueCollection)

使用任务对象将指定的名称/值集合上载到由指定 URI 标识的资源以作为异步操作。 Uploads the specified name/value collection to the resource identified by the specified URI as an asynchronous operation using a task object.

UploadValuesTaskAsync(Uri, NameValueCollection) UploadValuesTaskAsync(Uri, NameValueCollection) UploadValuesTaskAsync(Uri, NameValueCollection) UploadValuesTaskAsync(Uri, NameValueCollection)

使用任务对象将指定的名称/值集合上载到由指定 URI 标识的资源以作为异步操作。 Uploads the specified name/value collection to the resource identified by the specified URI as an asynchronous operation using a task object.

UploadValuesTaskAsync(Uri, String, NameValueCollection) UploadValuesTaskAsync(Uri, String, NameValueCollection) UploadValuesTaskAsync(Uri, String, NameValueCollection) UploadValuesTaskAsync(Uri, String, NameValueCollection)

使用任务对象将指定的名称/值集合上载到由指定 URI 标识的资源以作为异步操作。 Uploads the specified name/value collection to the resource identified by the specified URI as an asynchronous operation using a task object.

事件

Disposed Disposed Disposed Disposed

当通过调用 Dispose() 方法释放组件时发生。 Occurs when the component is disposed by a call to the Dispose() method.

(Inherited from Component)
DownloadDataCompleted DownloadDataCompleted DownloadDataCompleted DownloadDataCompleted

在异步数据下载操作完成时发生。 Occurs when an asynchronous data download operation completes.

DownloadFileCompleted DownloadFileCompleted DownloadFileCompleted DownloadFileCompleted

在异步文件下载操作完成时发生。 Occurs when an asynchronous file download operation completes.

DownloadProgressChanged DownloadProgressChanged DownloadProgressChanged DownloadProgressChanged

在异步下载操作成功传输部分或全部数据后发生。 Occurs when an asynchronous download operation successfully transfers some or all of the data.

DownloadStringCompleted DownloadStringCompleted DownloadStringCompleted DownloadStringCompleted

在异步资源下载操作完成时发生。 Occurs when an asynchronous resource-download operation completes.

OpenReadCompleted OpenReadCompleted OpenReadCompleted OpenReadCompleted

在以下异步操作完成时发生,该操作打开包含某个资源的流。 Occurs when an asynchronous operation to open a stream containing a resource completes.

OpenWriteCompleted OpenWriteCompleted OpenWriteCompleted OpenWriteCompleted

在打开流以将数据写入资源的异步操作完成时发生。 Occurs when an asynchronous operation to open a stream to write data to a resource completes.

UploadDataCompleted UploadDataCompleted UploadDataCompleted UploadDataCompleted

在异步数据上载操作完成时发生。 Occurs when an asynchronous data-upload operation completes.

UploadFileCompleted UploadFileCompleted UploadFileCompleted UploadFileCompleted

在异步文件上载操作完成时发生。 Occurs when an asynchronous file-upload operation completes.

UploadProgressChanged UploadProgressChanged UploadProgressChanged UploadProgressChanged

在异步上载操作成功转换部分或全部数据后发生。 Occurs when an asynchronous upload operation successfully transfers some or all of the data.

UploadStringCompleted UploadStringCompleted UploadStringCompleted UploadStringCompleted

在异步字符串上载操作完成时发生。 Occurs when an asynchronous string-upload operation completes.

UploadValuesCompleted UploadValuesCompleted UploadValuesCompleted UploadValuesCompleted

在名称/值集合的异步上载完成时发生。 Occurs when an asynchronous upload of a name/value collection completes.

WriteStreamClosed WriteStreamClosed WriteStreamClosed WriteStreamClosed

在使用写入流将数据写入资源的异步操作结束时发生。 Occurs when an asynchronous operation to write data to a resource using a write stream is closed.

安全性

WebPermission
若要访问请求的 URI 或请求重定向到任何 URI。 to access the requested URI or any URI that the request is redirected to. 关联枚举:Connect Associated enumeration: Connect.

适用于

另请参阅