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

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

FtpWebRequest.BeginGetRequestStream メソッド

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

書き込み用に、要求コンテンツ ストリーム非同期的なオープン開始します

名前空間: System.Net
アセンブリ: 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 override IAsyncResult BeginGetRequestStream (
    AsyncCallback callback,
    Object state
)
public:
virtual IAsyncResult^ BeginGetRequestStream (
    AsyncCallback^ callback, 
    Object^ state
) override
public IAsyncResult BeginGetRequestStream (
    AsyncCallback callback, 
    Object state
)
public override function BeginGetRequestStream
 (
    callback : AsyncCallback, 
    state : Object
) : IAsyncResult

パラメータ

callback

操作完了時に呼び出すメソッド参照する AsyncCallback デリゲート

state

操作に関する情報格納するユーザー定義のオブジェクト。このオブジェクトは、操作完了時に callback デリゲート渡されます。

戻り値
操作の状態を示す IAsyncResult インスタンス

例外例外
例外種類条件

InvalidOperationException

このメソッドまたは GetRequestStream の前回呼び出しがまだ完了していません。

WebException

FTP サーバーへの接続確立できませんでした

ProtocolViolationException

Method プロパティが、UploadFile に設定されていません。

解説解説
使用例使用例

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



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

辞書ショートカット

すべての辞書の索引

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

   

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



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

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

©2024 GRAS Group, Inc.RSS