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

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

WebRequest.ContentLength プロパティ

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

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

Public Overridable Property
 ContentLength As Long
Dim instance As WebRequest
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)

プロパティ値
送信している要求データのバイト数。

例外例外
例外の種類条件

NotImplementedException

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

解説解説

ContentLength プロパティは、WebRequest インスタンスによってインターネット リソースに送信されるデータのバイト数を格納します。

メモメモ

WebRequest クラスは、abstract クラスです。実行時の WebRequest インスタンスの実際の動作は、System.Net.WebRequest.Create メソッドで返される派生クラスによって決まります。既定値および例外の詳細については、HttpWebRequest や FileWebRequest などの派生クラスの説明を参照してください。

使用例使用例

ContentLength プロパティを発信バイト バッファのバイト数の値に設定する例を次に示します。


' Set the 'ContentType' property of the WebRequest.
myWebRequest.ContentType = "application/x-www-form-urlencoded"

' Set the 'ContentLength' property of the WebRequest.
myWebRequest.ContentLength = byteArray.Length
Dim newStream As Stream = myWebRequest.GetRequestStream()
newStream.Write(byteArray, 0, byteArray.Length)

' Close the Stream object.
newStream.Close()

' Assign the response object of 'WebRequest' to a 'WebResponse' variable.
Dim myWebResponse As WebResponse = myWebRequest.GetResponse()

// Set the 'ContentType' property of the WebRequest.
myWebRequest.ContentType="application/x-www-form-urlencoded";

// Set the 'ContentLength' property of the WebRequest.
myWebRequest.ContentLength=byteArray.Length;
Stream newStream=myWebRequest.GetRequestStream();
newStream.Write(byteArray,0,byteArray.Length);

// Close the Stream object.
newStream.Close();

// Assign the response object of 'WebRequest' to a 'WebResponse' variable.
WebResponse myWebResponse=myWebRequest.GetResponse();

// Set the 'ContentType' property of the WebRequest.
myWebRequest->ContentType = "application/x-www-form-urlencoded";

// Set the 'ContentLength' property of the WebRequest.
myWebRequest->ContentLength = byteArray->Length;
Stream^ newStream = myWebRequest->GetRequestStream();
newStream->Write( byteArray, 0, byteArray->Length );

// Close the Stream object.
newStream->Close();

// Assign the response object of 'WebRequest' to a 'WebResponse' variable.
WebResponse^ myWebResponse = myWebRequest->GetResponse();
// Set the 'ContentType' property of the WebRequest.
myWebRequest.set_ContentType("application/x-www-form-urlencoded");
// Set the 'ContentLength' property of the WebRequest.
myWebRequest.set_ContentLength(byteArray.get_Length());
Stream newStream = myWebRequest.GetRequestStream();
newStream.Write(byteArray, 0, byteArray.get_Length());
// Close the Stream object.
newStream.Close();
// Assign the response object of 'WebRequest' to a 'WebResponse' 
// variable.
WebResponse myWebResponse = myWebRequest.GetResponse();
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
WebRequest クラス
WebRequest メンバ
System.Net 名前空間
HttpWebRequest.ContentLength プロパティ



英和和英テキスト翻訳

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

辞書ショートカット

すべての辞書の索引

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

   

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



WebRequest.ContentLength プロパティのページの著作権

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

©2026 GRAS Group, Inc.RSS