FtpWebResponse.StatusDescription Propriedade

Definição

Obtém o texto que descreve um código de status enviado do servidor 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

Valor da propriedade

A instância String que contém o código de status e a mensagem retornada com essa resposta.

Exemplos

O exemplo de código a seguir envia uma solicitação para excluir um arquivo em um servidor FTP e exibe a mensagem status da resposta do servidor à solicitação.

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

Comentários

O texto retornado pela StatusDescription propriedade inclui o valor da propriedade de 3 dígitos StatusCode . Ao baixar dados, o valor das StatusDescription alterações como códigos status são retornados pelo servidor FTP. Depois de chamar o GetResponse método , StatusDescription ele contém um código de status intermediário. Quando você chama o Close método , StatusDescription contém o status final.

Aplica-se a

Confira também