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

Dim instance As FtpWebRequest Dim asyncResult As IAsyncResult Dim returnValue As Stream returnValue = instance.EndGetRequestStream(asyncResult)
戻り値
このインスタンスに関連付けられている、書き込み可能な Stream インスタンス。


操作が完了していない場合、EndGetRequestStream メソッドは操作が完了するまでブロックします。操作が完了したかどうかを確認するには、EndGetRequestStream を呼び出す前に、IsCompleted プロパティをチェックします。
「例外」で説明している例外に加えて、EndGetRequestStream は、書き込み用のストリームのオープン時にスローされた例外を再スローします。
![]() |
---|
このメンバは、アプリケーションでネットワーク トレースが有効にされている場合にトレース情報を出力します。詳細については、「ネットワークのトレース」を参照してください。 |

要求のストリームを取得するための非同期操作を終了するコード例を次に示します。このコード例は FtpWebRequest クラスの概要で取り上げているコード例の一部分です。
private static void EndGetStreamCallback(IAsyncResult ar) { FtpState state = (FtpState) ar.AsyncState; Stream requestStream = null; // End the asynchronous call to get the request stream. try { requestStream = state.Request.EndGetRequestStream(ar); // Copy the file contents to the request stream. const int bufferLength = 2048; byte[] buffer = new byte[bufferLength]; int count = 0; int readBytes = 0; FileStream stream = File.OpenRead(state.FileName); do { readBytes = stream.Read(buffer, 0, bufferLength); requestStream.Write(buffer, 0, readBytes); count += readBytes; } while (readBytes != 0); Console.WriteLine ("Writing {0} bytes to the stream.", count); // IMPORTANT: Close the request stream before sending the request. requestStream.Close(); // Asynchronously get the response to the upload request. state.Request.BeginGetResponse( new AsyncCallback (EndGetResponseCallback), state ); } // Return exceptions to the main application thread. catch (Exception e) { Console.WriteLine("Could not get the request stream."); state.OperationException = e; state.OperationComplete.Set(); return; } }
private: static void EndGetStreamCallback( IAsyncResult^ ar ) { FtpState^ state = dynamic_cast<FtpState^>(ar->AsyncState); Stream^ requestStream = nullptr; // End the asynchronous call to get the request stream. try { requestStream = state->Request->EndGetRequestStream( ar ); // Copy the file contents to the request stream. const int bufferLength = 2048; array<Byte>^buffer = gcnew array<Byte>(bufferLength); int count = 0; int readBytes = 0; FileStream^ stream = File::OpenRead( state->FileName ); do { readBytes = stream->Read( buffer, 0, bufferLength ); requestStream->Write( buffer, 0, bufferLength ); count += readBytes; } while ( readBytes != 0 ); Console::WriteLine( "Writing {0} bytes to the stream.", count ); // IMPORTANT: Close the request stream before sending the request. requestStream->Close(); // Asynchronously get the response to the upload request. state->Request->BeginGetResponse( gcnew AsyncCallback( EndGetResponseCallback ), state ); } // Return exceptions to the main application thread. catch ( Exception^ e ) { Console::WriteLine( "Could not get the request stream." ); state->OperationException = e; state->OperationComplete->Set(); return; } }

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

- FtpWebRequest.EndGetRequestStream メソッドのページへのリンク