NET FTP Library
DeleteDirectory Method
Example 






KellermanSoftware.NetFtpLibrary Namespace > FTP Class : DeleteDirectory Method
Delete a directory in the current FTP directory. It deletes all files and sub directories within a directory.
Syntax
'Declaration
 
Public Function DeleteDirectory( _
   ByVal ftpDirectory As System.String _
) As System.Boolean
'Usage
 
Dim instance As FTP
Dim ftpDirectory As System.String
Dim value As System.Boolean
 
value = instance.DeleteDirectory(ftpDirectory)
public System.bool DeleteDirectory( 
   System.string ftpDirectory
)
public function DeleteDirectory( 
    ftpDirectory: System.String
): System.Boolean; 
public function DeleteDirectory( 
   ftpDirectory : System.String
) : System.boolean;
public: System.bool DeleteDirectory( 
   System.string* ftpDirectory
) 
public:
System.bool DeleteDirectory( 
   System.String^ ftpDirectory
) 

Parameters

ftpDirectory

Return Value

True if the directory is successfully deleted
Example
FTP ftp = new FTP(); //Trial Mode            
//FTP ftp = new FTP("place user name here", "place license key here");
 
// set the name of the FTP server( its URL )
ftp.HostAddress = "ftp.fsz.bme.hu"; // a hungarian university. change this to your ftp server
ftp.UserName = "anonymous"; // replace with your user name
ftp.Password = "user@mail.com"; // replace with your password
 
 
//Delete a directory in the current FTP directory 
//It deletes all files and subdirectories within a directory 
System.Console.WriteLine("We are trying to delete all files in the TestDir directory and all its subdirs");
 
bool status = false;
 
status = ftp.DeleteDirectory("TestDir");
 
System.Console.WriteLine("TestDir and all its files and subfolders {0} deleted", status == true ? "has been" : "could not be");
Dim ftp As FTP = New FTP() 'Trial Mode
'FTP ftp = new FTP("place user name here", "place license key here");
 
' set the name of the FTP server( its URL )
ftp.HostAddress = "ftp.fsz.bme.hu" ' a hungarian university. change this to your ftp server
ftp.UserName = "anonymous" ' replace with your user name
ftp.Password = "user@mail.com" ' replace with your password
 
 
'Delete a directory in the current FTP directory 
'It deletes all files and subdirectories within a directory 
System.Console.WriteLine("We are trying to delete all files in the TestDir directory and all its subdirs")
 
Dim status As Boolean = False
 
status = ftp.DeleteDirectory("TestDir")
 
If status = True Then
    System.Console.WriteLine("TestDir and all its files and subfolders {0} deleted","has been")
Else
    System.Console.WriteLine("TestDir and all its files and subfolders {0} deleted","could not be")
End If
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

FTP Class
FTP Members