WebClient.DownloadData メソッド
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
指定した URI から Byte 配列としてリソースをダウンロードします。
オーバーロード
DownloadData(String) |
指定した URI から Byte 配列としてリソースをダウンロードします。 |
DownloadData(Uri) |
指定した URI から Byte 配列としてリソースをダウンロードします。 |
DownloadData(String)
- ソース:
- WebClient.cs
- ソース:
- WebClient.cs
- ソース:
- WebClient.cs
指定した URI から Byte 配列としてリソースをダウンロードします。
public:
cli::array <System::Byte> ^ DownloadData(System::String ^ address);
public byte[] DownloadData (string address);
member this.DownloadData : string -> byte[]
Public Function DownloadData (address As String) As Byte()
パラメーター
- address
- String
データのダウンロード元の URI。
戻り値
ダウンロードされたリソースを格納している Byte 配列。
例外
address
パラメーターが null
です。
このメソッドは、複数のスレッドで同時に呼び出されています。
例
次のコード例では、サーバーからデータを要求し、返されたデータを表示します。 には、 remoteUri
要求されたデータの有効な URI が含まれていることを前提としています。
Console::Write( "\nPlease enter a URI (e.g. http://www.contoso.com): " );
String^ remoteUri = Console::ReadLine();
// Create a new WebClient instance.
WebClient^ myWebClient = gcnew WebClient;
// Download home page data.
Console::WriteLine( "Downloading {0}", remoteUri );
// Download the Web resource and save it into a data buffer.
array<Byte>^ myDataBuffer = myWebClient->DownloadData( remoteUri );
// Display the downloaded data.
String^ download = Encoding::ASCII->GetString( myDataBuffer );
Console::WriteLine( download );
Console::WriteLine( "Download successful." );
Console.Write("\nPlease enter a URI (for example, http://www.contoso.com): ");
string remoteUri = Console.ReadLine();
// Create a new WebClient instance.
WebClient myWebClient = new WebClient();
// Download home page data.
Console.WriteLine("Downloading " + remoteUri);
// Download the Web resource and save it into a data buffer.
byte[] myDataBuffer = myWebClient.DownloadData (remoteUri);
// Display the downloaded data.
string download = Encoding.ASCII.GetString(myDataBuffer);
Console.WriteLine(download);
Console.WriteLine("Download successful.");
Console.Write(ControlChars.Cr + "Please enter a Url(for example, http://www.msn.com): ")
Dim remoteUrl As String = Console.ReadLine()
' Create a new WebClient instance.
Dim myWebClient As New WebClient()
' Download the home page data.
Console.WriteLine(("Downloading " + remoteUrl))
' DownloadData() method takes a 'uriRemote.ToString()' and downloads the Web resource and saves it into a data buffer.
Dim myDatabuffer As Byte() = myWebClient.DownloadData(remoteUrl)
' Display the downloaded data.
Dim download As String = Encoding.ASCII.GetString(myDataBuffer)
Console.WriteLine(download)
Console.WriteLine("Download successful.")
注釈
メソッドは DownloadData 、 パラメーターで指定された URI を使用してリソースを address
ダウンロードします。 このメソッドは、リソースのダウンロード中にブロックします。 リソースをダウンロードし、サーバーの応答の待機中に実行を続けるには、いずれかのメソッドを DownloadDataAsync 使用します。
プロパティが BaseAddress 空の文字列 ("") address
ではなく、絶対 URI を含まない場合は、 address
と組み合わせて BaseAddress 、要求されたデータの絶対 URI を形成する相対 URI である必要があります。 プロパティが空の QueryString 文字列でない場合は、 に address
追加されます。
このメソッドは、RETR コマンドを使用して FTP リソースをダウンロードします。 HTTP リソースの場合は、GET メソッドが使用されます。
Note
このメンバーは、アプリケーションでネットワーク トレースが有効にされている場合にトレース情報を出力します。 詳細については、「.NET Frameworkのネットワーク トレース」を参照してください。
適用対象
DownloadData(Uri)
- ソース:
- WebClient.cs
- ソース:
- WebClient.cs
- ソース:
- WebClient.cs
指定した URI から Byte 配列としてリソースをダウンロードします。
public:
cli::array <System::Byte> ^ DownloadData(Uri ^ address);
public byte[] DownloadData (Uri address);
member this.DownloadData : Uri -> byte[]
Public Function DownloadData (address As Uri) As Byte()
パラメーター
戻り値
ダウンロードされたリソースを格納している Byte 配列。
例外
address
パラメーターが null
です。
注釈
メソッドは DownloadData 、 パラメーターで指定された URI を使用してリソースを address
ダウンロードします。 このメソッドは、リソースのダウンロード中にブロックします。 リソースをダウンロードし、サーバーの応答の待機中に実行を続けるには、いずれかのメソッドを DownloadDataAsync 使用します。
プロパティが BaseAddress 空の文字列 ("") address
ではなく、絶対 URI を含まない場合は、 address
と組み合わせて BaseAddress 、要求されたデータの絶対 URI を形成する相対 URI である必要があります。 プロパティが空の QueryString 文字列でない場合は、 に address
追加されます。
このメソッドは、RETR コマンドを使用して FTP リソースをダウンロードします。 HTTP リソースの場合は、GET メソッドが使用されます。
Note
このメンバーは、アプリケーションでネットワーク トレースが有効にされている場合にトレース情報を出力します。 詳細については、「.NET Frameworkのネットワーク トレース」を参照してください。
適用対象
.NET
フィードバック
https://aka.ms/ContentUserFeedback」を参照してください。
以下は間もなく提供いたします。2024 年を通じて、コンテンツのフィードバック メカニズムとして GitHub の issue を段階的に廃止し、新しいフィードバック システムに置き換えます。 詳細については、「フィードバックの送信と表示