WebRequest.GetRequestStream メソッド
アセンブリ: System (system.dll 内)

Dim instance As WebRequest Dim returnValue As Stream returnValue = instance.GetRequestStream
インターネット リソースにデータを書き込む Stream。


GetRequestStream メソッドは、インターネット リソースにデータを送信するために要求を初期化し、インターネット リソースにデータを送信するための Stream インスタンスを返します。
GetRequestStream メソッドは、Stream への同期アクセスを提供します。非同期アクセスでは、BeginGetRequestStream メソッドと EndGetRequestStream メソッドを使用します。
![]() |
---|
WebRequest クラスは、abstract クラスです。実行時の WebRequest インスタンスの実際の動作は、System.Net.WebRequest.Create メソッドで返される派生クラスによって決まります。既定値および例外の詳細については、HttpWebRequest や FileWebRequest などの派生クラスの説明を参照してください。 |

GetRequestStream メソッドを使用して、ストリームを取得し、そのストリームにデータを書き込む例を次に示します。
' 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();

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に収録されているすべての辞書からWebRequest.GetRequestStream メソッドを検索する場合は、下記のリンクをクリックしてください。

- WebRequest.GetRequestStream メソッドのページへのリンク