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

Public Overrides Function BeginGetRequestStream ( _ 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.BeginGetRequestStream(callback, state)
public: virtual IAsyncResult^ BeginGetRequestStream ( AsyncCallback^ callback, Object^ state ) override
public override function BeginGetRequestStream ( callback : AsyncCallback, state : Object ) : IAsyncResult
戻り値
操作の状態を示す IAsyncResult インスタンス。


EndGetRequestStream メソッドを呼び出して、非同期操作を完了する必要があります。通常、EndGetRequestStream は、callback で参照されるメソッドによって呼び出されます。操作の状態を確認するには、このメソッドで返される IAsyncResult オブジェクトのプロパティをチェックします。
このメソッドは、ストリームの待機中もブロックしません。ブロックするには、このメソッドの代わりに GetRequestStream を呼び出します。
非同期プログラミング モデルの使用法の詳細については、「同期メソッドの非同期呼び出し」を参照してください。
![]() |
---|
このメンバは、アプリケーションでネットワーク トレースが有効にされている場合にトレース情報を出力します。詳細については、「ネットワークのトレース」を参照してください。 |

要求のストリームを取得するための非同期操作を開始するコード例を次に示します。このコード例は FtpWebRequest クラスの概要で取り上げているコード例の一部分です。
// Command line arguments are two strings: // 1. The url that is the name of the file being uploaded to the server. // 2. The name of the file on the local machine. // public static void Main(string[] args) { // Create a Uri instance with the specified URI string. // If the URI is not correctly formed, the Uri constructor // will throw an exception. ManualResetEvent waitObject; Uri target = new Uri (args[0]); string fileName = args[1]; FtpState state = new FtpState(); FtpWebRequest request = (FtpWebRequest)WebRequest.Create(target); request.Method = WebRequestMethods.Ftp.UploadFile; // This example uses anonymous logon. // The request is anonymous by default; the credential does not have to be specified. // The example specifies the credential only to // control how actions are logged on the server. request.Credentials = new NetworkCredential ("anonymous" ,"janeDoe@contoso.com"); // Store the request in the object that we pass into the // asynchronous operations. state.Request = request; state.FileName = fileName; // Get the event to wait on. waitObject = state.OperationComplete; // Asynchronously get the stream for the file contents. request.BeginGetRequestStream( new AsyncCallback (EndGetStreamCallback), state ); // Block the current thread until all operations are complete. waitObject.WaitOne(); // The operations either completed or threw an exception. if (state.OperationException != null) { throw state.OperationException; } else { Console.WriteLine("The operation completed - {0}", state.StatusDescription); } }
// Command line arguments are two strings: // 1. The url that is the name of the file being uploaded to the server. // 2. The name of the file on the local machine. // static void Main() { array<String^>^args = Environment::GetCommandLineArgs(); // Create a Uri instance with the specified URI string. // If the URI is not correctly formed, the Uri constructor // will throw an exception. ManualResetEvent^ waitObject; Uri^ target = gcnew Uri( args[ 1 ] ); String^ fileName = args[ 2 ]; FtpState^ state = gcnew FtpState; FtpWebRequest ^ request = dynamic_cast<FtpWebRequest^>(WebRequest::Create( target )); request->Method = WebRequestMethods::Ftp::UploadFile; // This example uses anonymous logon. // The request is anonymous by default; the credential does not have to be specified. // The example specifies the credential only to // control how actions are logged on the server. request->Credentials = gcnew NetworkCredential( "anonymous","janeDoe@contoso.com" ); // Store the request in the object that we pass into the // asynchronous operations. state->Request = request; state->FileName = fileName; // Get the event to wait on. waitObject = state->OperationComplete; // Asynchronously get the stream for the file contents. request->BeginGetRequestStream( gcnew AsyncCallback( EndGetStreamCallback ), state ); // Block the current thread until all operations are complete. waitObject->WaitOne(); // The operations either completed or threw an exception. if ( state->OperationException != nullptr ) { throw state->OperationException; } else { Console::WriteLine( "The operation completed - {0}", state->StatusDescription ); } }

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.BeginGetRequestStream メソッドを検索する場合は、下記のリンクをクリックしてください。

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