ylbtech-System.Net.WebClient.cs |
1.程序集 System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089返回頂部 |
1、
#region 程序集 System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 // C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.dll #endregion using System.Collections.Specialized; using System.ComponentModel; using System.IO; using System.Net.Cache; using System.Runtime; using System.Runtime.InteropServices; using System.Text; namespace System.Net { // // 摘要: // 提供向 URI 標識的資源發送數據和從 URI 標識的資源接收數據的公共方法。 [ComVisible(true)] public class WebClient : Component { // // 摘要: // 初始化 System.Net.WebClient 類的新實例。 public WebClient(); // // 摘要: // 獲取或設置 System.Net.WebClient 發出請求的基 URI。 // // 返回結果: // System.String,包含 System.Net.WebClient 請求的基 URI;如果尚未指定基地址,則為 System.String.Empty。 // // 異常: // T:System.ArgumentException: // System.Net.WebClient.BaseAddress 被設置為無效的 URI。內部異常可能包含有助於找到錯誤的信息。 public string BaseAddress { get; set; } // // 摘要: // 獲取或設置發送到主機並用於對請求進行身份驗證的網絡憑據。 // // 返回結果: // 一個 System.Net.ICredentials,包含該請求的身份驗證憑據。默認值為 null。 public ICredentials Credentials { get; set; } // // 摘要: // 獲取或設置 System.Boolean 值,該值控制 System.Net.CredentialCache.DefaultCredentials 是否隨請求一起發送。 // // 返回結果: // 如果使用默認憑據,則為 true;否則為 false。默認值為 false。 public bool UseDefaultCredentials { get; set; } // // 摘要: // 獲取或設置與請求關聯的標頭名稱/值對集合。 // // 返回結果: // 一個 System.Net.WebHeaderCollection,包含與此請求關聯的標頭名稱/值對。 public WebHeaderCollection Headers { get; set; } // // 摘要: // 獲取或設置與請求關聯的查詢名稱/值對集合。 // // 返回結果: // 一個 System.Collections.Specialized.NameValueCollection,包含與請求關聯的查詢名稱/值對。如果沒有與請求關聯的名稱/值對,則值為空的 // System.Collections.Specialized.NameValueCollection。 public NameValueCollection QueryString { get; set; } // // 摘要: // 獲取與響應關聯的標頭名稱/值對集合。 // // 返回結果: // System.Net.WebHeaderCollection,包含與響應關聯的標頭名稱/值對;如果尚未收到任何響應,則為 null。 public WebHeaderCollection ResponseHeaders { get; } // // 摘要: // 獲取或設置此 System.Net.WebClient 對象使用的代理。 // // 返回結果: // 用於發送請求的 System.Net.IWebProxy 實例。 // // 異常: // T:System.ArgumentNullException: // System.Net.WebClient.Proxy 被設置為 null。 public IWebProxy Proxy { get; set; } // // 摘要: // 對於此 WebClient 實例使用 System.Net.WebRequest 對象獲得的任何資源,獲取或設置應用程序的緩存策略。 // // 返回結果: // 一個 System.Net.Cache.RequestCachePolicy 對象,表示應用程序的緩存要求。 public RequestCachePolicy CachePolicy { get; set; } // // 摘要: // 獲取和設置用於上載和下載字符串的 System.Text.Encoding。 // // 返回結果: // 用於對字符串進行編碼的 System.Text.Encoding。此屬性的默認值為 System.Text.Encoding.Default 返回的編碼。 public Encoding Encoding { get; set; } // // 摘要: // 了解是否存在進行中的 Web 請求。 // // 返回結果: // 如果存在進行中的 Web 請求,則為 true;否則為 false。 public bool IsBusy { get; } // // 摘要: // 在打開流以將數據寫入資源的異步操作完成時發生。 public event OpenWriteCompletedEventHandler OpenWriteCompleted; // // 摘要: // 在異步資源下載操作完成時發生。 public event DownloadStringCompletedEventHandler DownloadStringCompleted; // // 摘要: // 在異步數據下載操作完成時發生。 public event DownloadDataCompletedEventHandler DownloadDataCompleted; // // 摘要: // 在異步文件下載操作完成時發生。 public event AsyncCompletedEventHandler DownloadFileCompleted; // // 摘要: // 在異步字符串上載操作完成時發生。 public event UploadStringCompletedEventHandler UploadStringCompleted; // // 摘要: // 在異步數據上載操作完成時發生。 public event UploadDataCompletedEventHandler UploadDataCompleted; // // 摘要: // 在異步文件上載操作完成時發生。 public event UploadFileCompletedEventHandler UploadFileCompleted; // // 摘要: // 在名稱/值集合的異步上載完成時發生。 public event UploadValuesCompletedEventHandler UploadValuesCompleted; // // 摘要: // 在以下異步操作完成時發生,該操作打開包含某個資源的流。 public event OpenReadCompletedEventHandler OpenReadCompleted; // // 摘要: // 在異步下載操作成功轉換部分或全部數據后發生。 public event DownloadProgressChangedEventHandler DownloadProgressChanged; // // 摘要: // 在異步上載操作成功轉換部分或全部數據后發生。 public event UploadProgressChangedEventHandler UploadProgressChanged; // // 摘要: // 取消一個掛起的異步操作。 public void CancelAsync(); // // 摘要: // 以 System.Byte 數組形式通過指定的 URI 下載資源。 // // 參數: // address: // 從中下載數據的 URI。 // // 返回結果: // 一個 System.Byte 數組,其中包含下載的資源。 // // 異常: // T:System.Net.WebException: // 通過組合 System.Net.WebClient.BaseAddress 和 address 所構成的 URI 無效。- 或 -下載數據時發生錯誤。 // // T:System.NotSupportedException: // 該方法已在多個線程上同時調用。 public byte[] DownloadData(string address); // // 摘要: // 以 System.Byte 數組形式通過指定的 URI 下載資源。 // // 參數: // address: // 由 System.Uri 對象表示的 URI,將從中下載數據。 // // 返回結果: // 一個 System.Byte 數組,其中包含下載的資源。 public byte[] DownloadData(Uri address); // // 摘要: // 以 System.Byte 數組形式下載指定的資源。此方法不會阻止調用線程。 // // 參數: // address: // 包含要下載的 URI 的 System.Uri。 // // 異常: // T:System.Net.WebException: // 通過組合 System.Net.WebClient.BaseAddress 和 address 所構成的 URI 無效。- 或 -下載資源時出現錯誤。 [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")] public void DownloadDataAsync(Uri address); // // 摘要: // 以 System.Byte 數組形式下載指定的資源。此方法不會阻止調用線程。 // // 參數: // address: // 包含要下載的 URI 的 System.Uri。 // // userToken: // 一個用戶定義對象,此對象將被傳遞給完成異步操作時所調用的方法。 // // 異常: // T:System.Net.WebException: // 通過組合 System.Net.WebClient.BaseAddress 和 address 所構成的 URI 無效。- 或 -下載資源時出現錯誤。 public void DownloadDataAsync(Uri address, object userToken); // // 摘要: // 將具有指定 URI 的資源下載到本地文件。 // // 參數: // address: // 從中下載數據的 URI。 // // fileName: // 要接收數據的本地文件的名稱。 // // 異常: // T:System.Net.WebException: // 通過組合 System.Net.WebClient.BaseAddress 和 address 所構成的 URI 無效。- 或 -filename 為 null // 或 System.String.Empty。- 或 -文件不存在。- 或 - 下載數據時發生錯誤。 // // T:System.NotSupportedException: // 該方法已在多個線程上同時調用。 public void DownloadFile(string address, string fileName); // // 摘要: // 將具有指定 URI 的資源下載到本地文件。 // // 參數: // address: // 以 System.String 形式指定的 URI,將從中下載數據。 // // fileName: // 要接收數據的本地文件的名稱。 // // 異常: // T:System.Net.WebException: // 通過組合 System.Net.WebClient.BaseAddress 和 address 所構成的 URI 無效。- 或 -filename 為 null // 或 System.String.Empty。- 或 -文件不存在。 - 或 -下載數據時發生錯誤。 // // T:System.NotSupportedException: // 該方法已在多個線程上同時調用。 public void DownloadFile(Uri address, string fileName); // // 摘要: // 將具有指定 URI 的資源下載到本地文件。此方法不會阻止調用線程。 // // 參數: // address: // 要下載的資源的 URI。 // // fileName: // 要放在本地計算機上的文件的名稱。 // // userToken: // 一個用戶定義對象,此對象將被傳遞給完成異步操作時所調用的方法。 // // 異常: // T:System.Net.WebException: // 通過組合 System.Net.WebClient.BaseAddress 和 address 所構成的 URI 無效。- 或 -下載資源時出現錯誤。 // // T:System.InvalidOperationException: // fileName 指定的本地文件正由另一個線程使用。 public void DownloadFileAsync(Uri address, string fileName, object userToken); // // 摘要: // 將具有指定 URI 的資源下載到本地文件。此方法不會阻止調用線程。 // // 參數: // address: // 要下載的資源的 URI。 // // fileName: // 要放在本地計算機上的文件的名稱。 // // 異常: // T:System.Net.WebException: // 通過組合 System.Net.WebClient.BaseAddress 和 address 所構成的 URI 無效。- 或 -下載資源時出現錯誤。 // // T:System.InvalidOperationException: // fileName 指定的本地文件正由另一個線程使用。 [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")] public void DownloadFileAsync(Uri address, string fileName); // // 摘要: // 以 System.String 形式下載請求的資源。以包含 URI 的 System.String 的形式指定要下載的資源。 // // 參數: // address: // 包含要下載的 URI 的 System.String。 // // 返回結果: // 一個 System.String,其中包含請求的資源。 // // 異常: // T:System.Net.WebException: // 通過組合 System.Net.WebClient.BaseAddress 和 address 所構成的 URI 無效。- 或 -下載資源時出現錯誤。 // // T:System.NotSupportedException: // 該方法已在多個線程上同時調用。 public string DownloadString(string address); // // 摘要: // 以 System.String 形式下載請求的資源。以 System.Uri 形式指定要下載的資源。 // // 參數: // address: // 一個 System.Uri 對象,其中包含要下載的 URI。 // // 返回結果: // 一個 System.String,其中包含請求的資源。 // // 異常: // T:System.Net.WebException: // 通過組合 System.Net.WebClient.BaseAddress 和 address 所構成的 URI 無效。- 或 -下載資源時出現錯誤。 // // T:System.NotSupportedException: // 該方法已在多個線程上同時調用。 public string DownloadString(Uri address); // // 摘要: // 將指定的字符串下載到指定的資源。此方法不會阻止調用線程。 // // 參數: // address: // 包含要下載的 URI 的 System.Uri。 // // userToken: // 一個用戶定義對象,此對象將被傳遞給完成異步操作時所調用的方法。 // // 異常: // T:System.Net.WebException: // 通過組合 System.Net.WebClient.BaseAddress 和 address 所構成的 URI 無效。- 或 -下載資源時出現錯誤。 public void DownloadStringAsync(Uri address, object userToken); // // 摘要: // 下載以 System.Uri 形式指定的資源。此方法不會阻止調用線程。 // // 參數: // address: // 包含要下載的 URI 的 System.Uri。 // // 異常: // T:System.Net.WebException: // 通過組合 System.Net.WebClient.BaseAddress 和 address 所構成的 URI 無效。- 或 -下載資源時出現錯誤。 [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")] public void DownloadStringAsync(Uri address); // // 摘要: // 為從具有 System.String 指定的 URI 的資源下載的數據打開一個可讀的流。 // // 參數: // address: // 以 System.String 形式指定的 URI,將從中下載數據。 // // 返回結果: // 一個 System.IO.Stream,用於從資源讀取數據。 // // 異常: // T:System.Net.WebException: // 通過組合 System.Net.WebClient.BaseAddress 和 address 所構成的 URI 無效。- 或 -下載數據時發生錯誤。 public Stream OpenRead(string address); // // 摘要: // 為從具有 System.Uri 指定的 URI 的資源下載的數據打開一個可讀的流 // // 參數: // address: // 以 System.Uri 形式指定的 URI,將從中下載數據。 // // 返回結果: // 一個 System.IO.Stream,用於從資源讀取數據。 // // 異常: // T:System.Net.WebException: // 通過組合 System.Net.WebClient.BaseAddress 和 address 所構成的 URI 無效。- 或 -下載數據時發生錯誤。 public Stream OpenRead(Uri address); // // 摘要: // 打開包含指定資源的可讀流。此方法不會阻止調用線程。 // // 參數: // address: // 要檢索的資源的 URI。 // // 異常: // T:System.Net.WebException: // 通過組合 System.Net.WebClient.BaseAddress 和 address 所構成的 URI 無效。- 或 -下載資源時出現錯誤。- // 或 -打開流時發生錯誤。 [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")] public void OpenReadAsync(Uri address); // // 摘要: // 打開包含指定資源的可讀流。此方法不會阻止調用線程。 // // 參數: // address: // 要檢索的資源的 URI。 // // userToken: // 一個用戶定義對象,此對象將被傳遞給完成異步操作時所調用的方法。 // // 異常: // T:System.Net.WebException: // 通過組合 System.Net.WebClient.BaseAddress 和 address 所構成的 URI 無效。- 或 -下載資源時出現錯誤。- // 或 -打開流時發生錯誤。 public void OpenReadAsync(Uri address, object userToken); // // 摘要: // 打開一個流以將數據寫入指定的資源。 // // 參數: // address: // 接收數據的資源的 URI。 // // 返回結果: // 用於將數據寫入資源的 System.IO.Stream。 // // 異常: // T:System.Net.WebException: // 通過組合 System.Net.WebClient.BaseAddress 和 address 所構成的 URI 無效。- 或 -打開流時發生錯誤。 public Stream OpenWrite(string address); // // 摘要: // 打開一個流以使用指定的方法向指定的資源寫入數據。 // // 參數: // address: // 接收數據的資源的 URI。 // // method: // 用於將數據發送到資源的方法。如果為 null,則對於 http 默認值為 POST,對於 ftp 默認值為 STOR。 // // 返回結果: // 用於將數據寫入資源的 System.IO.Stream。 // // 異常: // T:System.Net.WebException: // 通過組合 System.Net.WebClient.BaseAddress 和 address 所構成的 URI 無效。- 或 -打開流時發生錯誤。 public Stream OpenWrite(string address, string method); // // 摘要: // 打開一個流以使用指定的方法將數據寫入指定的資源。 // // 參數: // address: // 接收數據的資源的 URI。 // // method: // 用於將數據發送到資源的方法。如果為 null,則對於 http 默認值為 POST,對於 ftp 默認值為 STOR。 // // 返回結果: // 用於將數據寫入資源的 System.IO.Stream。 // // 異常: // T:System.Net.WebException: // 通過組合 System.Net.WebClient.BaseAddress 和 address 所構成的 URI 無效。- 或 -打開流時發生錯誤。 public Stream OpenWrite(Uri address, string method); // // 摘要: // 打開一個流以將數據寫入指定的資源。 // // 參數: // address: // 接收數據的資源的 URI。 // // 返回結果: // 用於將數據寫入資源的 System.IO.Stream。 // // 異常: // T:System.Net.WebException: // 通過組合 System.Net.WebClient.BaseAddress 和 address 所構成的 URI 無效。- 或 -打開流時發生錯誤。 [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")] public Stream OpenWrite(Uri address); // // 摘要: // 打開一個流以將數據寫入指定的資源。此方法不會阻止調用線程。 // // 參數: // address: // 接收數據的資源的 URI。 [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")] public void OpenWriteAsync(Uri address); // // 摘要: // 打開一個流以使用指定的方法向指定的資源寫入數據。此方法不會阻止調用線程。 // // 參數: // address: // 接收數據的資源的 URI。 // // method: // 用於將數據發送到資源的方法。如果為 null,則對於 http 默認值為 POST,對於 ftp 默認值為 STOR。 // // userToken: // 一個用戶定義對象,此對象將被傳遞給完成異步操作時所調用的方法 // // 異常: // T:System.Net.WebException: // 通過組合 System.Net.WebClient.BaseAddress 和 address 所構成的 URI 無效。- 或 -打開流時發生錯誤。 public void OpenWriteAsync(Uri address, string method, object userToken); // // 摘要: // 打開一個流以將數據寫入指定的資源。此方法不會阻止調用線程。 // // 參數: // address: // 接收數據的資源的 URI。 // // method: // 用於將數據發送到資源的方法。如果為 null,則對於 http 默認值為 POST,對於 ftp 默認值為 STOR。 [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")] public void OpenWriteAsync(Uri address, string method); // // 摘要: // 將數據緩沖區上載到由 URI 標識的資源。 // // 參數: // address: // 接收數據的資源的 URI。 // // data: // 要發送到資源的數據緩沖。 // // 返回結果: // 一個 System.Byte 數組,它包含來自資源的響應的正文。 // // 異常: // T:System.Net.WebException: // 通過組合 System.Net.WebClient.BaseAddress 和 address 所構成的 URI 無效。- 或 -data 為 null。- // 或 -發送數據時出錯。- 或 -承載資源的服務器沒有響應。 public byte[] UploadData(string address, byte[] data); // // 摘要: // 使用指定的方法將數據緩沖區上載到指定資源。 // // 參數: // address: // 接收數據的資源的 URI。 // // method: // 用於將數據發送到資源的 HTTP 方法。如果為 null,則對於 http 默認值為 POST,對於 ftp 默認值為 STOR。 // // data: // 要發送到資源的數據緩沖。 // // 返回結果: // 一個 System.Byte 數組,它包含來自資源的響應的正文。 // // 異常: // T:System.Net.WebException: // 通過組合 System.Net.WebClient.BaseAddress 和 address 所構成的 URI 無效。- 或 -data 為 null。- // 或 -上載數據時出錯。- 或 -承載資源的服務器沒有響應。 public byte[] UploadData(string address, string method, byte[] data); // // 摘要: // 使用指定的方法將數據緩沖區上載到指定資源。 // // 參數: // address: // 接收數據的資源的 URI。 // // method: // 用於將數據發送到資源的 HTTP 方法。如果為 null,則對於 http 默認值為 POST,對於 ftp 默認值為 STOR。 // // data: // 要發送到資源的數據緩沖。 // // 返回結果: // 一個 System.Byte 數組,它包含來自資源的響應的正文。 // // 異常: // T:System.Net.WebException: // 通過組合 System.Net.WebClient.BaseAddress 和 address 所構成的 URI 無效。- 或 -data 為 null。- // 或 -上載數據時出錯。- 或 -承載資源的服務器沒有響應。 public byte[] UploadData(Uri address, string method, byte[] data); // // 摘要: // 將數據緩沖區上載到由 URI 標識的資源。 // // 參數: // address: // 接收數據的資源的 URI。 // // data: // 要發送到資源的數據緩沖。 // // 返回結果: // 一個 System.Byte 數組,它包含來自資源的響應的正文。 // // 異常: // T:System.Net.WebException: // 通過組合 System.Net.WebClient.BaseAddress 和 address 所構成的 URI 無效。- 或 -data 為 null。- // 或 -發送數據時出錯。- 或 -承載資源的服務器沒有響應。 [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")] public byte[] UploadData(Uri address, byte[] data); // // 摘要: // 使用指定的方法和標識標記將數據緩沖區上載到由 URI 標識的資源。 // // 參數: // address: // 接收數據的資源的 URI。 // // method: // 用於將文件發送到資源的 HTTP 方法。如果為 null,則對於 http 默認值為 POST,對於 ftp 默認值為 STOR。 // // data: // 要發送到資源的數據緩沖。 // // userToken: // 一個用戶定義對象,此對象將被傳遞給完成異步操作時所調用的方法。 // // 異常: // T:System.Net.WebException: // 通過組合 System.Net.WebClient.BaseAddress 和 address 所構成的 URI 無效。- 或 -打開流時發生錯誤。- 或 // -承載資源的服務器沒有響應。 public void UploadDataAsync(Uri address, string method, byte[] data, object userToken); // // 摘要: // 使用 POST 方法將數據緩沖區上載到由 URI 標識的資源。此方法不會阻止調用線程。 // // 參數: // address: // 接收數據的資源的 URI。 // // data: // 要發送到資源的數據緩沖。 // // 異常: // T:System.Net.WebException: // 通過組合 System.Net.WebClient.BaseAddress 和 address 所構成的 URI 無效。- 或 -打開流時發生錯誤。- 或 // -承載資源的服務器沒有響應。 [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")] public void UploadDataAsync(Uri address, byte[] data); // // 摘要: // 使用指定的方法將數據緩沖區上載到由 URI 標識的資源。此方法不會阻止調用線程。 // // 參數: // address: // 接收數據的資源的 URI。 // // method: // 用於將文件發送到資源的 HTTP 方法。如果為 null,則對於 http 默認值為 POST,對於 ftp 默認值為 STOR。 // // data: // 要發送到資源的數據緩沖。 // // 異常: // T:System.Net.WebException: // 通過組合 System.Net.WebClient.BaseAddress 和 address 所構成的 URI 無效。- 或 -打開流時發生錯誤。- 或 // -承載資源的服務器沒有響應。 [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")] public void UploadDataAsync(Uri address, string method, byte[] data); // // 摘要: // 使用指定的方法將指定的本地文件上載到指定的資源。 // // 參數: // address: // 接收文件的資源的 URI。 // // method: // 用於將文件發送到資源的 HTTP 方法。如果為 null,則對於 http 默認值為 POST,對於 ftp 默認值為 STOR。 // // fileName: // 要發送到資源的文件。 // // 返回結果: // 一個 System.Byte 數組,它包含來自資源的響應的正文。 // // 異常: // T:System.Net.WebException: // 通過組合 System.Net.WebClient.BaseAddress 和 address 所構成的 URI 無效。- 或 -fileName 為 null、為 // System.String.Empty、包含無效字符或者不存在。- 或 -上載文件時出錯。- 或 -承載資源的服務器沒有響應。- 或 -Content-type // 標頭以 multipart 開頭。 public byte[] UploadFile(string address, string method, string fileName); // // 摘要: // 使用指定的方法將指定的本地文件上載到指定的資源。 // // 參數: // address: // 接收文件的資源的 URI。 // // method: // 用於將文件發送到資源的 HTTP 方法。如果為 null,則對於 http 默認值為 POST,對於 ftp 默認值為 STOR。 // // fileName: // 要發送到資源的文件。 // // 返回結果: // 一個 System.Byte 數組,它包含來自資源的響應的正文。 // // 異常: // T:System.Net.WebException: // 通過組合 System.Net.WebClient.BaseAddress 和 address 所構成的 URI 無效。- 或 -fileName 為 null、為 // System.String.Empty、包含無效字符或者不存在。- 或 -上載文件時出錯。- 或 -承載資源的服務器沒有響應。- 或 -Content-type // 標頭以 multipart 開頭。 public byte[] UploadFile(Uri address, string method, string fileName); // // 摘要: // 將指定的本地文件上載到具有指定 URI 的資源。 // // 參數: // address: // 接收文件的資源的 URI。例如,ftp://localhost/samplefile.txt。 // // fileName: // 要發送到資源的文件。例如,“samplefile.txt”。 // // 返回結果: // 一個 System.Byte 數組,它包含來自資源的響應的正文。 // // 異常: // T:System.Net.WebException: // 通過組合 System.Net.WebClient.BaseAddress 和 address 所構成的 URI 無效。- 或 -fileName 為 null、為 // System.String.Empty、包含無效字符或者不存在。- 或 -上載文件時出錯。- 或 -承載資源的服務器沒有響應。- 或 -Content-type // 標頭以 multipart 開頭。 [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")] public byte[] UploadFile(Uri address, string fileName); // // 摘要: // 將指定的本地文件上載到具有指定 URI 的資源。 // // 參數: // address: // 接收文件的資源的 URI。例如,ftp://localhost/samplefile.txt。 // // fileName: // 要發送到資源的文件。例如,“samplefile.txt”。 // // 返回結果: // 一個 System.Byte 數組,它包含來自資源的響應的正文。 // // 異常: // T:System.Net.WebException: // 通過組合 System.Net.WebClient.BaseAddress 和 address 所構成的 URI 無效。- 或 -fileName 為 null、為 // System.String.Empty、包含無效字符或者不存在。- 或 -上載文件時出錯。- 或 -承載資源的服務器沒有響應。- 或 -Content-type // 標頭以 multipart 開頭。 public byte[] UploadFile(string address, string fileName); // // 摘要: // 使用 POST 方法將指定的本地文件上載到指定的資源。此方法不會阻止調用線程。 // // 參數: // address: // 接收文件的資源的 URI。對於 HTTP 資源,此 URI 必須標識可以接受用 POST 方法發送的請求的資源,如腳本或 ASP 頁。 // // fileName: // 要發送到資源的文件。 // // 異常: // T:System.Net.WebException: // 通過組合 System.Net.WebClient.BaseAddress 和 address 所構成的 URI 無效。- 或 -fileName 為 null、為 // System.String.Empty、包含無效字符或者指定的文件路徑不存在。- 或 -打開流時發生錯誤。- 或 -承載資源的服務器沒有響應。- 或 -Content-type // 標頭以 multipart 開頭。 [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")] public void UploadFileAsync(Uri address, string fileName); // // 摘要: // 使用 POST 方法將指定的本地文件上載到指定的資源。此方法不會阻止調用線程。 // // 參數: // address: // 接收文件的資源的 URI。對於 HTTP 資源,此 URI 必須標識可以接受用 POST 方法發送的請求的資源,如腳本或 ASP 頁。 // // method: // 用於將數據發送到資源的 HTTP 方法。如果為 null,則對於 http 默認值為 POST,對於 ftp 默認值為 STOR。 // // fileName: // 要發送到資源的文件。 // // 異常: // T:System.Net.WebException: // 通過組合 System.Net.WebClient.BaseAddress 和 address 所構成的 URI 無效。- 或 -fileName 為 null、為 // System.String.Empty、包含無效字符或者指定的文件路徑不存在。- 或 -打開流時發生錯誤。- 或 -承載資源的服務器沒有響應。- 或 -Content-type // 標頭以 multipart 開頭。 [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")] public void UploadFileAsync(Uri address, string method, string fileName); // // 摘要: // 使用 POST 方法將指定的本地文件上載到指定的資源。此方法不會阻止調用線程。 // // 參數: // address: // 接收文件的資源的 URI。對於 HTTP 資源,此 URI 必須標識可以接受用 POST 方法發送的請求的資源,如腳本或 ASP 頁。 // // method: // 用於將數據發送到資源的 HTTP 方法。如果為 null,則對於 http 默認值為 POST,對於 ftp 默認值為 STOR。 // // fileName: // 要發送到資源的文件。 // // userToken: // 一個用戶定義對象,此對象將被傳遞給完成異步操作時所調用的方法。 // // 異常: // T:System.Net.WebException: // 通過組合 System.Net.WebClient.BaseAddress 和 address 所構成的 URI 無效。- 或 -fileName 為 null、為 // System.String.Empty、包含無效字符或者指定的文件路徑不存在。- 或 -打開流時發生錯誤。- 或 -承載資源的服務器沒有響應。- 或 -Content-type // 標頭以 multipart 開頭。 public void UploadFileAsync(Uri address, string method, string fileName, object userToken); // // 摘要: // 使用指定的方法將指定的字符串上載到指定的資源。 // // 參數: // address: // 接收文件的資源的 URI。此 URI 必須標識可以接受使用 method 方法發送的請求的資源。 // // method: // 用於將字符串發送到資源的 HTTP 方法。如果為 null,則對於 http 默認值為 POST,對於 ftp 默認值為 STOR。 // // data: // 要上載的字符串。 // // 返回結果: // 一個 System.String,包含服務器發送的響應。 // // 異常: // T:System.Net.WebException: // 通過組合 System.Net.WebClient.BaseAddress 和 address 所構成的 URI 無效。- 或 -承載資源的服務器沒有響應。- // 或 -method 不能用來發送內容。 public string UploadString(Uri address, string method, string data); // // 摘要: // 使用指定的方法將指定的字符串上載到指定的資源。 // // 參數: // address: // 接收文件的資源的 URI。此 URI 必須標識可以接受使用 method 方法發送的請求的資源。 // // method: // 用於將字符串發送到資源的 HTTP 方法。如果為 null,則對於 http 默認值為 POST,對於 ftp 默認值為 STOR。 // // data: // 要上載的字符串。 // // 返回結果: // 一個 System.String,包含服務器發送的響應。 // // 異常: // T:System.Net.WebException: // 通過組合 System.Net.WebClient.BaseAddress 和 address 所構成的 URI 無效。- 或 -承載資源的服務器沒有響應。- // 或 -method 不能用來發送內容。 public string UploadString(string address, string method, string data); // // 摘要: // 使用 POST 方法將指定的字符串上載到指定的資源。 // // 參數: // address: // 要接收字符串的資源的 URI。對於 HTTP 資源,此 URI 必須標識可以接受用 POST 方法發送的請求的資源,如腳本或 ASP 頁。 // // data: // 要上載的字符串。 // // 返回結果: // 一個 System.String,包含服務器發送的響應。 // // 異常: // T:System.ArgumentNullException: // data 為 null。 // // T:System.Net.WebException: // 通過組合 System.Net.WebClient.BaseAddress 和 address 所構成的 URI 無效。- 或 -承載資源的服務器沒有響應。 public string UploadString(string address, string data); // // 摘要: // 使用 POST 方法將指定的字符串上載到指定的資源。 // // 參數: // address: // 要接收字符串的資源的 URI。對於 HTTP 資源,此 URI 必須標識可以接受用 POST 方法發送的請求的資源,如腳本或 ASP 頁。 // // data: // 要上載的字符串。 // // 返回結果: // 一個 System.String,包含服務器發送的響應。 // // 異常: // T:System.ArgumentNullException: // data 為 null。 // // T:System.Net.WebException: // 通過組合 System.Net.WebClient.BaseAddress 和 address 所構成的 URI 無效。- 或 -承載資源的服務器沒有響應。 [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")] public string UploadString(Uri address, string data); // // 摘要: // 將指定的字符串上載到指定的資源。此方法不會阻止調用線程。 // // 參數: // address: // 接收文件的資源的 URI。對於 HTTP 資源,此 URI 必須標識可以接受用 POST 方法發送的請求的資源,如腳本或 ASP 頁。 // // method: // 用於將文件發送到資源的 HTTP 方法。如果為 null,則對於 http 默認值為 POST,對於 ftp 默認值為 STOR。 // // data: // 要上載的字符串。 // // userToken: // 一個用戶定義對象,此對象將被傳遞給完成異步操作時所調用的方法。 // // 異常: // T:System.ArgumentNullException: // data 為 null。 // // T:System.Net.WebException: // 通過組合 System.Net.WebClient.BaseAddress 和 address 所構成的 URI 無效。- 或 -承載資源的服務器沒有響應。 public void UploadStringAsync(Uri address, string method, string data, object userToken); // // 摘要: // 將指定的字符串上載到指定的資源。此方法不會阻止調用線程。 // // 參數: // address: // 接收文件的資源的 URI。對於 HTTP 資源,此 URI 必須標識可以接受用 POST 方法發送的請求的資源,如腳本或 ASP 頁。 // // method: // 用於將文件發送到資源的 HTTP 方法。如果為 null,則對於 http 默認值為 POST,對於 ftp 默認值為 STOR。 // // data: // 要上載的字符串。 // // 異常: // T:System.ArgumentNullException: // data 為 null。 // // T:System.Net.WebException: // 通過組合 System.Net.WebClient.BaseAddress 和 address 所構成的 URI 無效。- 或 -承載資源的服務器沒有響應。 [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")] public void UploadStringAsync(Uri address, string method, string data); // // 摘要: // 將指定的字符串上載到指定的資源。此方法不會阻止調用線程。 // // 參數: // address: // 接收文件的資源的 URI。對於 HTTP 資源,此 URI 必須標識可以接受用 POST 方法發送的請求的資源,如腳本或 ASP 頁。 // // data: // 要上載的字符串。 // // 異常: // T:System.ArgumentNullException: // data 為 null。 // // T:System.Net.WebException: // 通過組合 System.Net.WebClient.BaseAddress 和 address 所構成的 URI 無效。- 或 -承載資源的服務器沒有響應。 [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")] public void UploadStringAsync(Uri address, string data); // // 摘要: // 使用指定的方法將指定的名稱/值集合上載到指定的 URI 所標識的資源。 // // 參數: // address: // 接收集合的資源的 URI。 // // method: // 用於將文件發送到資源的 HTTP 方法。如果為 null,則對於 http 默認值為 POST,對於 ftp 默認值為 STOR。 // // data: // 要發送到資源的 System.Collections.Specialized.NameValueCollection。 // // 返回結果: // 一個 System.Byte 數組,它包含來自資源的響應的正文。 // // 異常: // T:System.Net.WebException: // 通過組合 System.Net.WebClient.BaseAddress 和 address 所構成的 URI 無效。- 或 -data 為 null。- // 或 -打開流時發生錯誤。- 或 -承載資源的服務器沒有響應。- 或 -Content-type 標頭值既不是 null 也不是 application/x-www-form-urlencoded。 public byte[] UploadValues(string address, string method, NameValueCollection data); // // 摘要: // 將指定的名稱/值集合上載到指定的 URI 所標識的資源。 // // 參數: // address: // 接收集合的資源的 URI。 // // data: // 要發送到資源的 System.Collections.Specialized.NameValueCollection。 // // 返回結果: // 一個 System.Byte 數組,它包含來自資源的響應的正文。 // // 異常: // T:System.Net.WebException: // 通過組合 System.Net.WebClient.BaseAddress 和 address 所構成的 URI 無效。- 或 -data 為 null。- // 或 -承載資源的服務器沒有響應。- 或 -打開流時發生錯誤。- 或 -Content-type 標頭不是 null 或“application/x-www-form-urlencoded”。 [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")] public byte[] UploadValues(Uri address, NameValueCollection data); // // 摘要: // 使用指定的方法將指定的名稱/值集合上載到指定的 URI 所標識的資源。 // // 參數: // address: // 接收集合的資源的 URI。 // // method: // 用於將文件發送到資源的 HTTP 方法。如果為 null,則對於 http 默認值為 POST,對於 ftp 默認值為 STOR。 // // data: // 要發送到資源的 System.Collections.Specialized.NameValueCollection。 // // 返回結果: // 一個 System.Byte 數組,它包含來自資源的響應的正文。 // // 異常: // T:System.Net.WebException: // 通過組合 System.Net.WebClient.BaseAddress 和 address 所構成的 URI 無效。- 或 -data 為 null。- // 或 -打開流時發生錯誤。- 或 -承載資源的服務器沒有響應。- 或 -Content-type 標頭值既不是 null 也不是 application/x-www-form-urlencoded。 public byte[] UploadValues(Uri address, string method, NameValueCollection data); // // 摘要: // 將指定的名稱/值集合上載到指定的 URI 所標識的資源。 // // 參數: // address: // 接收集合的資源的 URI。 // // data: // 要發送到資源的 System.Collections.Specialized.NameValueCollection。 // // 返回結果: // 一個 System.Byte 數組,它包含來自資源的響應的正文。 // // 異常: // T:System.Net.WebException: // 通過組合 System.Net.WebClient.BaseAddress 和 address 所構成的 URI 無效。- 或 -data 為 null。- // 或 -承載資源的服務器沒有響應。- 或 -打開流時發生錯誤。- 或 -Content-type 標頭不是 null 或“application/x-www-form-urlencoded”。 public byte[] UploadValues(string address, NameValueCollection data); // // 摘要: // 使用指定的方法將指定的名稱/值集合中的數據上載到由指定的 URI 標識的資源。此方法不會阻止調用線程。 // // 參數: // address: // 接收集合的資源的 URI。此 URI 必須標識可以接受使用 method 方法發送的請求的資源。 // // method: // 用於將字符串發送到資源的方法。如果為 null,則對於 http 默認值為 POST,對於 ftp 默認值為 STOR。 // // data: // 要發送到資源的 System.Collections.Specialized.NameValueCollection。 // // 異常: // T:System.ArgumentNullException: // data 為 null。- 或 -address 為 null。 // // T:System.Net.WebException: // 通過組合 System.Net.WebClient.BaseAddress 和 address 所構成的 URI 無效。- 或 -承載資源的服務器沒有響應。- // 或 -method 不能用來發送內容。 [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")] public void UploadValuesAsync(Uri address, string method, NameValueCollection data); // // 摘要: // 將指定的名稱/值集合中的數據上載到由指定的 URI 標識的資源。此方法不會阻止調用線程。 // // 參數: // address: // 接收集合的資源的 URI。此 URI 必須標識可以接受使用默認方法發送的請求的資源。請參見“備注”。 // // data: // 要發送到資源的 System.Collections.Specialized.NameValueCollection。 // // 異常: // T:System.ArgumentNullException: // data 為 null。 // // T:System.Net.WebException: // 通過組合 System.Net.WebClient.BaseAddress 和 address 所構成的 URI 無效。- 或 -承載資源的服務器沒有響應。 [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")] public void UploadValuesAsync(Uri address, NameValueCollection data); // // 摘要: // 使用指定的方法將指定的名稱/值集合中的數據上載到由指定的 URI 標識的資源。此方法不會阻止調用線程,並允許調用方將對象傳遞給操作完成時所調用的方法。 // // 參數: // address: // 接收集合的資源的 URI。此 URI 必須標識可以接受使用 method 方法發送的請求的資源。 // // method: // 用於將字符串發送到資源的 HTTP 方法。如果為 null,則對於 http 默認值為 POST,對於 ftp 默認值為 STOR。 // // data: // 要發送到資源的 System.Collections.Specialized.NameValueCollection。 // // userToken: // 一個用戶定義對象,此對象將被傳遞給完成異步操作時所調用的方法。 // // 異常: // T:System.ArgumentNullException: // data 為 null。- 或 -address 為 null。 // // T:System.Net.WebException: // 通過組合 System.Net.WebClient.BaseAddress 和 address 所構成的 URI 無效。- 或 -承載資源的服務器沒有響應。- // 或 -method 不能用來發送內容。 public void UploadValuesAsync(Uri address, string method, NameValueCollection data, object userToken); // // 摘要: // 為指定資源返回一個 System.Net.WebRequest 對象。 // // 參數: // address: // 一個 System.Uri,用於標識要請求的資源。 // // 返回結果: // 一個新的 System.Net.WebRequest 對象,用於指定的資源。 protected virtual WebRequest GetWebRequest(Uri address); // // 摘要: // 返回對指定 System.Net.WebRequest 的 System.Net.WebResponse。 // // 參數: // request: // 用於獲取響應的 System.Net.WebRequest。 // // 返回結果: // System.Net.WebResponse 包含對指定 System.Net.WebRequest 的響應。 protected virtual WebResponse GetWebResponse(WebRequest request); // // 摘要: // 使用指定的 System.IAsyncResult 獲取對指定 System.Net.WebRequest 的 System.Net.WebResponse。 // // 參數: // request: // 用於獲取響應的 System.Net.WebRequest。 // // result: // 一個 System.IAsyncResult 對象,來自以前對 System.Net.WebRequest.BeginGetResponse(System.AsyncCallback,System.Object) // 的調用。 // // 返回結果: // System.Net.WebResponse 包含對指定 System.Net.WebRequest 的響應。 protected virtual WebResponse GetWebResponse(WebRequest request, IAsyncResult result); // // 摘要: // 引發 System.Net.WebClient.DownloadDataCompleted 事件。 // // 參數: // e: // 包含事件數據的 System.Net.DownloadDataCompletedEventArgs 對象。 protected virtual void OnDownloadDataCompleted(DownloadDataCompletedEventArgs e); // // 摘要: // 引發 System.Net.WebClient.DownloadFileCompleted 事件。 // // 參數: // e: // 包含事件數據的 System.ComponentModel.AsyncCompletedEventArgs 對象。 protected virtual void OnDownloadFileCompleted(AsyncCompletedEventArgs e); // // 摘要: // 引發 System.Net.WebClient.DownloadProgressChanged 事件。 // // 參數: // e: // 包含事件數據的 System.Net.DownloadProgressChangedEventArgs 對象。 protected virtual void OnDownloadProgressChanged(DownloadProgressChangedEventArgs e); // // 摘要: // 引發 System.Net.WebClient.DownloadStringCompleted 事件。 // // 參數: // e: // 包含事件數據的 System.Net.DownloadStringCompletedEventArgs 對象。 protected virtual void OnDownloadStringCompleted(DownloadStringCompletedEventArgs e); // // 摘要: // 引發 System.Net.WebClient.OpenReadCompleted 事件。 // // 參數: // e: // 包含事件數據的 System.Net.OpenReadCompletedEventArgs 對象。 protected virtual void OnOpenReadCompleted(OpenReadCompletedEventArgs e); // // 摘要: // 引發 System.Net.WebClient.OpenWriteCompleted 事件。 // // 參數: // e: // 包含事件數據的 System.Net.OpenWriteCompletedEventArgs 對象。 protected virtual void OnOpenWriteCompleted(OpenWriteCompletedEventArgs e); // // 摘要: // 引發 System.Net.WebClient.UploadDataCompleted 事件。 // // 參數: // e: // 包含事件數據的 System.Net.UploadDataCompletedEventArgs 對象。 protected virtual void OnUploadDataCompleted(UploadDataCompletedEventArgs e); // // 摘要: // 引發 System.Net.WebClient.UploadFileCompleted 事件。 // // 參數: // e: // 包含事件數據的 System.Net.UploadFileCompletedEventArgs 對象。 protected virtual void OnUploadFileCompleted(UploadFileCompletedEventArgs e); // // 摘要: // 引發 System.Net.WebClient.UploadProgressChanged 事件。 // // 參數: // e: // 包含事件數據的 System.Net.UploadProgressChangedEventArgs 對象。 protected virtual void OnUploadProgressChanged(UploadProgressChangedEventArgs e); // // 摘要: // 引發 System.Net.WebClient.UploadStringCompleted 事件。 // // 參數: // e: // 包含事件數據的 System.Net.UploadStringCompletedEventArgs 對象。 protected virtual void OnUploadStringCompleted(UploadStringCompletedEventArgs e); // // 摘要: // 引發 System.Net.WebClient.UploadValuesCompleted 事件。 // // 參數: // e: // 包含事件數據的 System.Net.UploadValuesCompletedEventArgs 對象。 protected virtual void OnUploadValuesCompleted(UploadValuesCompletedEventArgs e); } }
2、
2.返回頂部 |
3. 摘要返回頂部 |
1、
// // 摘要: // 以 System.Byte 數組形式通過指定的 URI 下載資源。 // // 參數: // address: // 從中下載數據的 URI。 // // 返回結果: // 一個 System.Byte 數組,其中包含下載的資源。 // // 異常: // T:System.Net.WebException: // 通過組合 System.Net.WebClient.BaseAddress 和 address 所構成的 URI 無效。- 或 -下載數據時發生錯誤。 // // T:System.NotSupportedException: // 該方法已在多個線程上同時調用。 public byte[] DownloadData(string address);
2、
4.返回頂部 |
5.返回頂部 |
6.返回頂部 |
![]() |
作者:ylbtech 出處:http://ylbtech.cnblogs.com/ 本文版權歸作者和博客園共有,歡迎轉載,但未經作者同意必須保留此段聲明,且在文章頁面明顯位置給出原文連接,否則保留追究法律責任的權利。 |