FtpWebResponse Class
TOC
Collapse the table of content
Expand the table of content

FtpWebResponse Class

 

Encapsulates a File Transfer Protocol (FTP) server's response to a request.

Namespace:   System.Net
Assembly:  System (in System.dll)

System::Object
  System::MarshalByRefObject
    System.Net::WebResponse
      System.Net::FtpWebResponse

public ref class FtpWebResponse : WebResponse, IDisposable

NameDescription
System_CAPS_pubpropertyBannerMessage

Gets the message sent by the FTP server when a connection is established prior to logon.

System_CAPS_pubpropertyContentLength

Gets the length of the data received from the FTP server.(Overrides WebResponse::ContentLength.)

System_CAPS_pubpropertyContentType

When overridden in a derived class, gets or sets the content type of the data being received.(Inherited from WebResponse.)

System_CAPS_pubpropertyExitMessage

Gets the message sent by the server when the FTP session is ending.

System_CAPS_pubpropertyHeaders

This API supports the product infrastructure and is not intended to be used directly from your code. Gets an empty WebHeaderCollection object.(Overrides WebResponse::Headers.)

System_CAPS_pubpropertyIsFromCache

Gets a Boolean value that indicates whether this response was obtained from the cache.(Inherited from WebResponse.)

System_CAPS_pubpropertyIsMutuallyAuthenticated

Gets a Boolean value that indicates whether mutual authentication occurred.(Inherited from WebResponse.)

System_CAPS_pubpropertyLastModified

Gets the date and time that a file on an FTP server was last modified.

System_CAPS_pubpropertyResponseUri

Gets the URI that sent the response to the request.(Overrides WebResponse::ResponseUri.)

System_CAPS_pubpropertyStatusCode

Gets the most recent status code sent from the FTP server.

System_CAPS_pubpropertyStatusDescription

Gets text that describes a status code sent from the FTP server.

System_CAPS_pubpropertySupportsHeaders

Gets a value that indicates whether the Headers property is supported by the FtpWebResponse instance.(Overrides WebResponse::SupportsHeaders.)

System_CAPS_pubpropertyWelcomeMessage

Gets the message sent by the FTP server when authentication is complete.

NameDescription
System_CAPS_pubmethodClose()

Frees the resources held by the response.(Overrides WebResponse::Close().)

System_CAPS_pubmethodCreateObjRef(Type^)

Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.(Inherited from MarshalByRefObject.)

System_CAPS_pubmethodDispose()

Releases the unmanaged resources used by the WebResponse object.(Inherited from WebResponse.)

System_CAPS_protmethodDispose(Boolean)

Releases the unmanaged resources used by the WebResponse object, and optionally disposes of the managed resources.(Inherited from WebResponse.)

System_CAPS_pubmethodEquals(Object^)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_protmethodFinalize()

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetLifetimeService()

Retrieves the current lifetime service object that controls the lifetime policy for this instance.(Inherited from MarshalByRefObject.)

System_CAPS_protmethodGetObjectData(SerializationInfo^, StreamingContext)

This API supports the product infrastructure and is not intended to be used directly from your code. Populates a SerializationInfo with the data that is needed to serialize the target object.(Inherited from WebResponse.)

System_CAPS_pubmethodGetResponseStream()

Retrieves the stream that contains response data sent from an FTP server.(Overrides WebResponse::GetResponseStream().)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethodInitializeLifetimeService()

Obtains a lifetime service object to control the lifetime policy for this instance.(Inherited from MarshalByRefObject.)

System_CAPS_protmethodMemberwiseClone()

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_protmethodMemberwiseClone(Boolean)

Creates a shallow copy of the current MarshalByRefObject object.(Inherited from MarshalByRefObject.)

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

NameDescription
System_CAPS_pubinterfaceSystem_CAPS_privmethodISerializable::GetObjectData(SerializationInfo^, StreamingContext)

This API supports the product infrastructure and is not intended to be used directly from your code. Populates a SerializationInfo instance with the data that is needed to serialize WebResponse. (Inherited from WebResponse.)

Instances of FtpWebResponse are obtained by calling the GetResponse method. The returned object must be cast to an FtpWebResponse. When your application no longer needs the FtpWebResponse object, call the Close method to free the resources held by the FtpWebResponse.

The StatusCode property contains the status code returned by the server, and the StatusDescription property returns the status code and a message that describes the status. The values returned by these properties change as the messages are returned by the server.

Any data returned by the request, such as the list of file names returned for a ListDirectory request, is available in the stream returned by the GetResponseStream method. The length of the stream data can be obtained from the ContentLength property.

The following code example sends a request to delete a file on an FTP server and displays the status message from the server's response to the request. For additional examples, see the members of the WebRequestMethods::Ftp and FtpWebRequest classes.

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

.NET Framework
Available since 2.0

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show:
© 2016 Microsoft