FtpWebRequest.Method プロパティ
アセンブリ: System (system.dll 内)

public: virtual property String^ Method { String^ get () override; void set (String^ value) override; }
public override function get Method () : String public override function set Method (value : String)
サーバーに送信するための FTP コマンドを格納している String 値。既定値は DownloadFile です。


Method プロパティによって、サーバーに送信されるコマンドが決まります。通常、WebRequestMethods.Ftp 構造体で定義された文字列を使用して Method を設定します。Method を UploadFile に設定する場合は、GetRequestStream メソッドを呼び出す前に行う必要があります。これらのメンバを正しい順序で呼び出すことができなかった場合は、要求ストリームを取得しようとすると ProtocolViolationException 例外が発生します。
FtpWebRequest オブジェクトに提供される資格情報には、指定したメソッドを実行するためのアクセス許可が必要です。アクセス許可がない場合、FTP コマンドは失敗します。
Method を、サーバーで認識されるいずれかのコマンドに設定し、FtpWebRequest オブジェクトを使用して、そのコマンドを送信できます。この方法は、そのコマンドがデータを送信する必要がなく、サーバーが要求を受けてデータを送信しない場合にだけ正常に動作します。
接続の状態を変更するコマンドを送信することはできません。たとえば、"MODE"、"PASV"、または "PORT" の各コマンドは使用しないでください。接続の状態を変更するコマンドを使用すると、要求および基になる接続が使用できない状態のままになる可能性があります。コマンドが成功したか失敗したかを確認するには、Status プロパティと StatusDescription プロパティをチェックします。

このプロパティを DeleteFile に設定するコード例を次に示します。
public static bool DeleteFileOnServer(Uri serverUri) { // The serverUri parameter should use the ftp:// scheme. // It contains the name of the server file that is to be deleted. // Example: ftp://contoso.com/someFile.txt. // if (serverUri.Scheme != Uri.UriSchemeFtp) { return false; } // Get the object used to communicate with the server. FtpWebRequest request = (FtpWebRequest)WebRequest.Create(serverUri); request.Method = WebRequestMethods.Ftp.DeleteFile; FtpWebResponse response = (FtpWebResponse) request.GetResponse(); Console.WriteLine("Delete status: {0}",response.StatusDescription); response.Close(); return true; }

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.Method プロパティを検索する場合は、下記のリンクをクリックしてください。

- FtpWebRequest.Method プロパティのページへのリンク