Prince OfThief Prince OfThief - 2 months ago 24
C# Question

How to recursively delete a folder with the files within using FtpWebRequest?

I want to delete a folder in FTP and it's files recursively.

Any example code do I can implement?

Answer

Nice Little example you can find here:

http://msdn.microsoft.com/en-us/library/system.net.ftpwebrequest.aspx

In the example they used WebRequestMethods.Ftp.UploadFile class to direct what kind of operation they want to do.

Use the WebRequestMethods.Ftp.RemoveDirectory method once you have a handle on the parent directory you want to delete:

http://msdn.microsoft.com/en-us/library/system.net.webrequestmethods.ftp.aspx