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

Dim instance As WebResponse Dim value As Long value = instance.ContentLength instance.ContentLength = value
/** @property */ public long get_ContentLength () /** @property */ public void set_ContentLength (long value)
インターネット リソースから返されるバイト数。


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();

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


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

- WebResponse.ContentLength プロパティのページへのリンク