Free Support Forum - aspose.com

Errror while Deleteting remote Directory

Hi ,
I try to Delete remote directory by using following code but i was unalbe to delete the directory from ftp.

Aspose.Network.Ftp.FtpClient T20 = new Aspose.Network.Ftp.FtpClient();
T20.Connect(host, true);
T20.RemoveDirectory(item.remotePath);


Is any one Help me how to directory with containg all files from remote server.

Hi,

Thanks for considering Aspose.

The RemoveDirectory() method deletes the folders that exist in the currently selected directory.

For example, you have the following heirarchy:

--/

----folder1

--------folder1-1

----folder2

If you want to delete "folder1-1", you need to first change directory to "folder1", then call the RemoveDirectory() method.

The sample could might look like:

try

{

client = new FtpClient("host", 21, "anonymous", "password");

client.Connect( true );

// Change current directory

client.ChangeDirectory("folder1");

// remove folder under the current directory

client.RemoveDirectory("folder2");

}

catch( Aspose.Network.Ftp.FtpException fe )

{

Messages.ShowMessage( fe.ToString() );

}