FtpWebRequest.EndGetRequestStream メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > FtpWebRequest.EndGetRequestStream メソッドの意味・解説 

FtpWebRequest.EndGetRequestStream メソッド

メモ : このメソッドは、.NET Framework version 2.0新しく追加されたものです。

BeginGetRequestStream で開始され保留中の非同期操作終了します

名前空間: System.Net
アセンブリ: System (system.dll 内)
構文構文

Public Overrides Function
 EndGetRequestStream ( _
    asyncResult As IAsyncResult _
) As Stream
Dim instance As FtpWebRequest
Dim asyncResult As IAsyncResult
Dim returnValue As Stream

returnValue = instance.EndGetRequestStream(asyncResult)
public override Stream EndGetRequestStream (
    IAsyncResult asyncResult
)
public:
virtual Stream^ EndGetRequestStream (
    IAsyncResult^ asyncResult
) override
public Stream EndGetRequestStream (
    IAsyncResult asyncResult
)
public override function EndGetRequestStream
 (
    asyncResult : IAsyncResult
) : Stream

パラメータ

asyncResult

操作開始時に返された IAsyncResult オブジェクト

戻り値
このインスタンス関連付けられている、書き込み可能な Stream インスタンス

例外例外
例外種類条件

ArgumentNullException

asyncResultnull 参照 (Visual Basic では Nothing) です。

ArgumentException

BeginGetRequestStream呼び出しで、asyncResult取得されませんでした

InvalidOperationException

このメソッドは、asyncResult識別される操作に対して既に呼び出されています。

解説解説
使用例使用例

要求ストリーム取得するための非同期操作終了するコード例次に示します。このコード例は 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;
      }
   }
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
FtpWebRequest クラス
FtpWebRequest メンバ
System.Net 名前空間
FtpWebResponse
FtpStatusCode 列挙
WebRequestMethods.Ftp
WebRequest
WebResponse
WebClient


このページでは「.NET Framework クラス ライブラリ リファレンス」からFtpWebRequest.EndGetRequestStream メソッドを検索した結果を表示しています。
Weblioに収録されているすべての辞書からFtpWebRequest.EndGetRequestStream メソッドを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からFtpWebRequest.EndGetRequestStream メソッド を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

FtpWebRequest.EndGetRequestStream メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



FtpWebRequest.EndGetRequestStream メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS