FtpWebRequest.UsePassive プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > FtpWebRequest.UsePassive プロパティの意味・解説 

FtpWebRequest.UsePassive プロパティ

メモ : このプロパティは、.NET Framework version 2.0 で新しく追加されたものです。

クライアント アプリケーションのデータ転送処理の動作を取得または設定します。

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

例外例外
例外の種類条件

InvalidOperationException

既に処理中の要求で、このプロパティに対して新しい値が指定されました。

解説解説

UsePassive プロパティを true に設定すると、サーバーに "PASV" コマンドが送信されます。このコマンドはサーバーに対して、データ ポートで待機し、転送コマンドの受信時に接続を開始するのではなく、接続を待つように要求します。

UsePassive の使用によって指定される動作の詳細については、RFC 959 『File Transfer Protocol』(http://www.rfc-editor.org/) の Section 3.2 「Establishing Data Connections」および Section 4.1.2 「Transfer Parameter Commands」を参照してください。

GetRequestStream、BeginGetRequestStream、GetResponse、または BeginGetResponse の各メソッドを呼び出した後に UsePassive を変更すると、InvalidOperationException 例外が発生します。

UsePassive が true に設定されている場合は、FTP サーバーがファイルのサイズを送信せず、ダウンロードの進行状況が常に 0 になることがあります。UsePassive が false に設定されている場合は、ファイアウォールで警告が発生し、ファイルのダウンロードがブロックされることがあります。

使用例使用例

指定した FtpWebRequest オブジェクトのプロパティ値を、取得したり表示したりするコード例を次に示します。

// DisplayRequestProperties prints a request's properties.
// This method should be called after the request is sent to the server.
       
private static void DisplayRequestProperties(FtpWebRequest
 request)
{
    Console.WriteLine("User {0} {1}", 
        request.Credentials.GetCredential(request.RequestUri,"basic").UserName
,
        request.RequestUri
    );
    Console.WriteLine("Request: {0} {1}", 
        request.Method,
        request.RequestUri
    );
    Console.WriteLine("Passive: {0}  Keep alive: {1}  Binary: {2} Timeout: {3}.",
 
        request.UsePassive, 
        request.KeepAlive, 
        request.UseBinary,
        request.Timeout == -1 ? "none" : request.Timeout.ToString()
    );
    IWebProxy proxy = request.Proxy;
    if (proxy != null)
    {
        Console.WriteLine("Proxy: {0}", proxy.GetProxy(request.RequestUri));
    } 
    else
    {
        Console.WriteLine("Proxy: (none)");
    }
    
    Console.WriteLine("ConnectionGroup: {0}",
        request.ConnectionGroupName == null ? "none"
 : request.ConnectionGroupName
    );

    Console.WriteLine("Encrypted connection: {0}", 
        request.EnableSsl);

    Console.WriteLine("Method: {0}", request.Method);
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
FtpWebRequest クラス
FtpWebRequest メンバ
System.Net 名前空間
FtpWebResponse
FtpStatusCode 列挙体
WebRequestMethods.Ftp
WebRequest
WebResponse
WebClient



英和和英テキスト翻訳

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

辞書ショートカット

すべての辞書の索引

FtpWebRequest.UsePassive プロパティのお隣キーワード
検索ランキング

   

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



FtpWebRequest.UsePassive プロパティのページの著作権

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

©2026 GRAS Group, Inc.RSS