Removing a not-empty directoy

Aug 19, 2012 at 9:16 PM

Hello together,

 

does anyone knows, how can i remove a directory, which is not empty? When i use the methode RemoveDirectory, i get the message, that the deleting is not possible, because the directory is not empty.

I'm afraid, that i must remove the subdirectory and there file recursive. Is there an another way to deleting a not-empty directory?

 

Greetings from germany

Coordinator
Aug 20, 2012 at 8:29 PM

I'm afraid the only supported way is to do it recursively. I'm not aware of a server implementation that allows you to remove a non-empty directory but that's not to say they don't exist.

Aug 21, 2012 at 6:46 AM

Good morning,

i use pure ftpd 1.0.35.

I´ve tried to delete a not-empty directory with FileZilla and it´s works fine.

 

Thanks for your answer. In this case i must remove the directories recursive.

 

Btw. System.Net.FTPClient is a great library :-)

Coordinator
Aug 21, 2012 at 1:10 PM
GibsonSG wrote:
Btw. System.Net.FTPClient is a great library :-)

Thanks!

I suspect that FileZilla internally removes the objects under the directory recursively and then removes the directory itself as does other FTP client implementations.

Apr 22, 2014 at 2:37 PM
ftp.DeleteDirectory("Your Path", True, FtpListOption.AllFiles)

That's the solution to delete a non-empty directory. You have to set it to force delete your directory. "True" force to delete your diretory using "FtpListOption.AllFiles" where delete all files inside your directory first.

I'm using FileZilla too and this works perfect.