Friends,
In my last post, we saw how can we retrieve the list of all files & folders from a FTP server using C#. In this post, we will see how can we delete a file from FTP server using C# from within your Console or Windows Forms Application.
Here's the code:
- private string DeleteFile(string fileName)
- {
- FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://www.server.com/" + fileName);
- request.Method = WebRequestMethods.Ftp.DeleteFile;
- request.Credentials = new NetworkCredential("username", "password");
- using (FtpWebResponse response = (FtpWebResponse)request.GetResponse())
- {
- return response.StatusDescription;
- }
- }
Hope you like this post! Keep learning and sharing! Cheers!

Irving GutiérrezPosted Apr 28, 2022, 1:18 PM
Nice, thanks!
Rami IssaPosted Sep 28, 2020, 1:28 AM
Small article and direct to the point,thank you
Mazingaizo KunamaPosted Aug 14, 2019, 8:47 AM
Hi Nitesh am bbatlling to delete folders from ftp can you help
Ibrahim RashidPosted Jan 28, 2015, 3:30 AM
Nice article..small one with big impact.
Vithal WadjePosted Jan 27, 2015, 10:32 AM
nice to learn sir,thanks for sharing