FtpWebResponse.StatusDescription Właściwość

Definicja

Pobiera tekst opisujący kod stanu wysyłany z serwera 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

Wartość właściwości

String Wystąpienie zawierające kod stanu i komunikat zwrócony z tą odpowiedzią.

Przykłady

Poniższy przykład kodu wysyła żądanie usunięcia pliku na serwerze FTP i wyświetla komunikat o stanie z odpowiedzi serwera na żądanie.

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;
}

Uwagi

Tekst zwrócony przez StatusDescription właściwość zawiera wartość właściwości 3-cyfrową StatusCode . Podczas pobierania danych wartość StatusDescription zmian w postaci kodów stanu jest zwracana przez serwer FTP. Po wywołaniu GetResponse metody StatusDescription zawiera kod stanu pośredniego. Po wywołaniu Close metody StatusDescription zawiera stan końcowy.

Dotyczy

Zobacz też