Export (0) Print
Expand All

FtpWebResponse Class

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

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

'Declaration
Public Class FtpWebResponse _
	Inherits WebResponse _
	Implements IDisposable
'Usage
Dim instance As FtpWebResponse

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.

No code example is currently available or this language may not be supported.
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 = dynamic_cast<FtpWebRequest*>(WebRequest::Create(serverUri));
        request->Method = FtpMethods::DeleteFile;

        FtpWebResponse* response = dynamic_cast<FtpWebResponse*> (request->GetResponse());
        Console::WriteLine(S"Delete status: {0}",response->StatusDescription);  
        response->Close();
        return true;
    }

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

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0

Community Additions

ADD
Show:
© 2014 Microsoft