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.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
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類別提供常用的方法,將資料傳送至任何由 URI 識別的本機、內部網路或網際網路資源,或從中接收資料。The WebClient class provides common methods for sending data to or receiving data from any local, intranet, or Internet resource identified by a URI.

類別會使用類別WebRequest來提供資源的存取權。 WebClientThe 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 支援http:以、 https:ftp:file:配置識別碼開頭的 uri。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 將傳送Byte至資源,並傳回包含任何回應的陣列。 NameValueCollectionSends a NameValueCollection to the resource and returns a Byte array containing any response.
UploadValuesAsync Byte將傳送NameValueCollection至資源,並傳回包含任何回應的陣列,而不會封鎖呼叫執行緒。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 以的Stream形式傳回資源的資料。Returns 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在實例中true WebClient設定為。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 執行個體緩衝處理從網際網路資源讀取的資料。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 執行個體緩衝處理寫入網際網路資源的資料。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

取得包含 IContainerComponentGets 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

取得或設定用來上傳和下載字串的 EncodingGets or 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 物件使用的 Proxy。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

取得或設定 ComponentISiteGets or sets the ISite of the Component.

(Inherited from Component)
UseDefaultCredentials UseDefaultCredentials UseDefaultCredentials UseDefaultCredentials

取得或設定 Boolean 值,控制是否隨著要求傳送 DefaultCredentialsGets 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)

建立包含所有相關資訊的物件,這些資訊是產生用來與遠端物件通訊的所需 Proxy。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 所使用的 Unmanaged 資源,並選擇性地釋放 Managed 資源。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)

下載要求的資源做為 StringDownloads the requested resource as a String. 將要下載的資源指定為包含 URI 的 StringThe resource to download is specified as a String containing the URI.

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

下載要求的資源做為 StringDownloads the requested resource as a String. 將要下載的資源指定為 UriThe resource to download is specified as a Uri.

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

下載指定的資源做為 UriDownloads 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 下載資源做為 StringDownloads 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 下載資源做為 StringDownloads 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()

擷取控制這個執行個體存留期 (Lifetime) 原則的目前存留期服務物件。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()

取得目前執行個體的 TypeGets 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)

傳回指定之 WebResponseWebRequestReturns the WebResponse for the specified WebRequest.

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

使用指定的 WebResponse 傳回指定之 WebRequestIAsyncResultReturns 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 的淺層複本 (Shallow Copy)。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 名稱的 StringReturns 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)

使用指定的方法並辨識語彙基元 (Token),將資料緩衝區上載至由 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. 關聯的列舉型別:ConnectAssociated enumeration: Connect.

適用於

另請參閱