FtpClient.DeleteDirectory Method (String)

System.Net.FtpClient

Collapse image Expand Image Copy image CopyHover image
Deletes the specified directory on the server.

Namespace: System.Net.FtpClient
Assembly: System.Net.FtpClient (in System.Net.FtpClient.dll) Version: 1.0.5064.17461

Syntax

C#
public void DeleteDirectory(
	string path
)
Visual Basic
Public Sub DeleteDirectory ( 
	path As String
)
Visual C++
public:
virtual void DeleteDirectory(
	String^ path
) sealed

Parameters

path
Type: System..::..String
The full or relative path of the directory to delete

Implements

IFtpClient..::..DeleteDirectory(String)

Examples

C#  Copy imageCopy
using System;
using System.Net;
using System.Net.FtpClient;

namespace Examples {
    static class DeleteDirectoryExample {
        public static void DeleteDirectory() {
            using (FtpClient conn = new FtpClient()) {
                conn.Host = "localhost";
                conn.Credentials = new NetworkCredential("ftptest", "ftptest");

                // Remove the directory and all objects beneath it. The last parameter
                // forces System.Net.FtpClient to use LIST -a for getting a list of objects
                // beneath the specified directory.
                conn.DeleteDirectory("/path/to/directory", true, 
                    FtpListOption.AllFiles | FtpListOption.ForceList);
            }
        }
    }
}

See Also