PowerTCP FTP for .NET
DeleteDirectory Method
Example 



The absolute or relative path of the directory to remove.
Deletes a directory and all subfolders and files.
Syntax
Public Function DeleteDirectory( _
   ByVal rootDirectory As String _
) As List(Of Response)
Dim instance As Ftp
Dim rootDirectory As String
Dim value As List(Of Response)
 
value = instance.DeleteDirectory(rootDirectory)
public List<Response> DeleteDirectory( 
   string rootDirectory
)
public:
List<Response^>^ DeleteDirectory( 
   String^ rootDirectory
) 

Parameters

rootDirectory
The absolute or relative path of the directory to remove.

Return Value

A List of Response objects representing the files and directories that were acted upon.
Remarks
In the event of a failure an FtpProtocolException will be thrown that will contain the list of Response objects. The failed response will have code whose value is greater than 400. If you receive a '500 Directory not empty' error it could be an indication that the directory contains hidden files.
Example
This example demonstrates using the FTP control to delete files and subdirectories.
private void deleteFiles()
{
    //Delete a list of files (in this case, the txt files).
    ftp1.Delete(ftp1.ListDirectoryTree("MyTextFiles", "*.txt", false));

    //Delete a specific file.
    ftp1.Delete("MyTextFiles/test.dat");

    //Delete the directory, even when it is not empty.
    ftp1.DeleteDirectory("MyTextFiles");
}
Private Sub deleteFiles()
    'Delete a list of files (in this case, the txt files).
    ftp1.Delete(ftp1.ListDirectoryTree("MyTextFiles", "*.txt", False))

    'Delete a specific file.
    ftp1.Delete("MyTextFiles/test.dat")

    'Delete the directory, even when it is not empty.
    ftp1.DeleteDirectory("MyTextFiles")
End Sub
See Also

Reference

Ftp Class
Ftp Members


PowerTCP FTP for .NET Documentation Version 6.1
© 2023 Dart Communications. All Rights Reserved.
Send comments on this topic