FtpWebResponse.StatusDescription 屬性

定義

取得描述從 FTP 伺服器傳送之狀態碼的文字。

public:
 property System::String ^ StatusDescription { System::String ^ get(); };
public string? StatusDescription { get; }
public string StatusDescription { get; }
member this.StatusDescription : string
Public ReadOnly Property StatusDescription As String

屬性值

String 執行個體,包含與這個回應一起傳回的狀態碼和訊息。

範例

下列程式碼範例會傳送要求來刪除 FTP 伺服器上的檔案,並從伺服器的回應顯示狀態訊息。

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 = dynamic_cast<FtpWebRequest^>(WebRequest::Create( serverUri ));
   request->Method = WebRequestMethods::Ftp::DeleteFile;
   FtpWebResponse^ response = dynamic_cast<FtpWebResponse^>(request->GetResponse());
   Console::WriteLine( "Delete status: {0}", response->StatusDescription );
   response->Close();
   return true;
}
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;
}

備註

屬性傳回的 StatusDescription 文字包含 3 位數 StatusCode 的屬性值。 下載資料時,FTP 伺服器會傳回狀態碼時的變更值 StatusDescription 。 呼叫 GetResponse 方法之後, StatusDescription 會包含中繼狀態碼。 當您呼叫 方法時 CloseStatusDescription 會包含最終狀態。

適用於

另請參閱