WebResponse.ContentLength プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > WebResponse.ContentLength プロパティの意味・解説 

WebResponse.ContentLength プロパティ

派生クラスオーバーライドされると、受信しているデータコンテンツ長を取得または設定します

名前空間: System.Net
アセンブリ: System (system.dll 内)
構文構文

Public Overridable Property
 ContentLength As Long
Dim instance As WebResponse
Dim value As Long

value = instance.ContentLength

instance.ContentLength = value
public virtual long ContentLength { get; set;
 }
/** @property */
public long get_ContentLength ()

/** @property */
public void set_ContentLength (long value)
public function get ContentLength
 () : long

public function set ContentLength
 (value : long)

プロパティ
インターネット リソースから返されるバイト数。

例外例外
例外種類条件

NotSupportedException

プロパティ派生クラスオーバーライドされていないのに、そのプロパティ取得または設定試行されました。

解説解説

ContentLength プロパティは、インターネット リソースからの応答バイト長を格納しますヘッダー情報を含む要求メソッドでは、ContentLength にはヘッダー情報長さ含まれません。

メモメモ

WebResponse クラスは、abstract クラスです。実行時WebResponse インスタンス実際動作は、WebRequest.GetResponse で返される派生クラスによって決まります既定値および例外詳細については、HttpWebResponse や FileWebResponse などの派生クラス説明参照してください

使用例使用例

ContentLength プロパティ使用して返されリソース長さ取得する例を次に示します

' Create a 'WebRequest' with the specified url.     
Dim myWebRequest As WebRequest = WebRequest.Create("www.contoso.com")

' Send the 'WebRequest' and wait for response.
Dim myWebResponse As WebResponse = myWebRequest.GetResponse()

' The ContentLength and ContentType received as headers in the response
 object are also exposed as properties.
   ' These provide information about the length and type of the entity
 body in the response.
Console.WriteLine(ControlChars.Cr + "Content length :{0}, Content
 Type : {1}", myWebResponse.ContentLength, myWebResponse.ContentType)
myWebResponse.Close()

         // Create a 'WebRequest' with the specified url.
WebRequest myWebRequest = WebRequest.Create("http://www.contoso.com");
 

// Send the 'WebRequest' and wait for response.
WebResponse myWebResponse = myWebRequest.GetResponse(); 

// Display the content length and content type received as headers in
 the response object.
Console.WriteLine("\nContent length :{0}, Content Type : {1}", 
                             myWebResponse.ContentLength, 
                             myWebResponse.ContentType);  

// Release resources of response object.
myWebResponse.Close(); 

// Create a 'WebRequest' with the specified url.
WebRequest^ myWebRequest = WebRequest::Create( "http://www.contoso.com"
 );

// Send the 'WebRequest' and wait for response.
WebResponse^ myWebResponse = myWebRequest->GetResponse();

// Display the content length and content type received as headers in
 the response object.
Console::WriteLine( "\nContent length : {0}, Content Type : {1}", myWebResponse->ContentLength,
 myWebResponse->ContentType );

// Release resources of response object.
myWebResponse->Close();
// Create a 'WebRequest' with the specified url.
WebRequest myWebRequest = WebRequest.Create("http://www.contoso.com");
// Send the 'WebRequest' and wait for response.
WebResponse myWebResponse = myWebRequest.GetResponse();
// Display the content length and content type received as headers 
// in the response object.
Console.WriteLine("\nContent length :{0}, Content Type : {1}", 
    System.Convert.ToString(myWebResponse.get_ContentLength()),
    System.Convert.ToString(myWebResponse.get_ContentType()));
// Release resources of response object.
myWebResponse.Close();
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
WebResponse クラス
WebResponse メンバ
System.Net 名前空間
HttpWebResponse.ContentLength プロパティ



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

WebResponse.ContentLength プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



WebResponse.ContentLength プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS