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

Public Overrides Function BeginGetResponse ( _ callback As AsyncCallback, _ state As Object _ ) As IAsyncResult
Dim instance As FtpWebRequest Dim callback As AsyncCallback Dim state As Object Dim returnValue As IAsyncResult returnValue = instance.BeginGetResponse(callback, state)
public override function BeginGetResponse ( callback : AsyncCallback, state : Object ) : IAsyncResult
戻り値
操作の状態を示す IAsyncResult インスタンス。


EndGetResponse メソッドを呼び出して、非同期操作を完了する必要があります。通常、EndGetResponse は、callback で参照されるメソッドによって呼び出されます。操作の状態を確認するには、BeginGetResponse メソッドで返される IAsyncResult オブジェクトのプロパティをチェックします。
Proxy プロパティが、直接または構成ファイルのいずれかで設定された場合、FTP サーバーとの通信は、指定したプロキシを経由して行われます。
BeginGetResponse は、サーバーからの応答の待機中もブロックしません。ブロックするには、BeginGetResponse の代わりに GetResponse メソッドを呼び出します。
非同期プログラミング モデルの使用法の詳細については、「同期メソッドの非同期呼び出し」を参照してください。
このメンバは、アプリケーションでネットワーク トレースが有効にされている場合にトレース情報を出力します。詳細については、「ネットワークのトレース」を参照してください。
![]() |
---|
WebException がスローされた場合は、例外の Response プロパティと Status プロパティを使用してサーバーからの応答を確認します。 |

要求のストリームを取得するための非同期操作を終了してから、応答を取得する要求を開始するコード例を次に示します。このコード例は 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.BeginGetResponse メソッドを検索する場合は、下記のリンクをクリックしてください。

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