WebClient.BaseAddress プロパティ
アセンブリ: System (system.dll 内)

Dim instance As WebClient Dim value As String value = instance.BaseAddress instance.BaseAddress = value
/** @property */ public String get_BaseAddress () /** @property */ public void set_BaseAddress (String value)
WebClient で作成された要求のベース URI を格納する String。ベース アドレスが指定されていない場合は Empty。


BaseAddress プロパティは、相対アドレスと結合されるベース URI を格納します。データをアップロードまたはダウンロードするメソッドを呼び出すと、WebClient オブジェクトは、メソッド呼び出しで指定した相対アドレスとこのベース URI を結合します。絶対 URI を指定した場合、WebClient は BaseAddress プロパティ値を使用しません。
以前に設定した値を削除するには、このプロパティに null 参照 (Visual Basic では Nothing) または空の文字列 ("") を設定します。

インターネット サーバーからデータをダウンロードし、コンソールに表示するコード例を次に示します。サーバーのアドレス (http://www.contoso.com など) が hostUri にあり、リソースへのパス (/default.htm など) が uriSuffix にあることを前提にしています。
' Create a new WebClient instance. Dim myWebClient As New WebClient() ' Set the BaseAddress of the Web resource in the WebClient. myWebClient.BaseAddress = hostUri Console.WriteLine(("Downloading from " + hostUri + "/" + uriSuffix)) Console.WriteLine(ControlChars.Cr + "Press Enter key to continue") Console.ReadLine() ' Download the target Web resource into a byte array. Dim myDatabuffer As Byte() = myWebClient.DownloadData(uriSuffix) ' Display the downloaded data. Dim download As String = Encoding.ASCII.GetString(myDatabuffer) Console.WriteLine(download) Console.WriteLine(("Download of " + myWebClient.BaseAddress.ToString() + uriSuffix + " was successful."))
// Create a new WebClient instance. WebClient myWebClient = new WebClient(); // Set the BaseAddress of the Web Resource in the WebClient. myWebClient.BaseAddress = hostUri; Console.WriteLine("Downloading from " + hostUri + "/" + uriSuffix); Console.WriteLine("\nPress Enter key to continue"); Console.ReadLine(); // Download the target Web Resource into a byte array. byte[] myDatabuffer = myWebClient.DownloadData (uriSuffix); // Display the downloaded data. string download = Encoding.ASCII.GetString(myDatabuffer); Console.WriteLine(download); Console.WriteLine("Download of " + myWebClient.BaseAddress.ToString() + uriSuffix + " was successful.");
// Create a new WebClient instance. WebClient^ myWebClient = gcnew WebClient; // Set the BaseAddress of the Web Resource in the WebClient. myWebClient->BaseAddress = hostUri; Console::WriteLine( "Downloading from {0}/ {1}", hostUri, uriSuffix ); Console::WriteLine( "\nPress Enter key to continue" ); Console::ReadLine(); // Download the target Web Resource into a Byte array. array<Byte>^ myDatabuffer = myWebClient->DownloadData( uriSuffix ); // Display the downloaded data. String^ download = Encoding::ASCII->GetString( myDatabuffer ); Console::WriteLine( download ); Console::WriteLine( "Download of {0}{1} was successful.", myWebClient->BaseAddress, uriSuffix );
// Create a new WebClient instance. WebClient myWebClient = new WebClient(); // Set the BaseAddress of the Web Resource in the WebClient. myWebClient.set_BaseAddress(hostUri); Console.WriteLine("Downloading from " + hostUri + "/" + uriSuffix); Console.WriteLine("\nPress Enter key to continue"); Console.ReadLine(); // Download the target Web Resource into a byte array. ubyte myDatabuffer[] = myWebClient.DownloadData(uriSuffix); // Display the downloaded data. String download = Encoding.get_ASCII().GetString(myDatabuffer); Console.WriteLine(download); Console.WriteLine("Download of " + myWebClient.get_BaseAddress(). ToString() + uriSuffix + " was successful.");

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からWebClient.BaseAddress プロパティを検索する場合は、下記のリンクをクリックしてください。

- WebClient.BaseAddress プロパティのページへのリンク