My application is deleting a file from the ftp in about 15s no matter the size.
FileZilla, on the other hand, deletes the same file instantly.
Here is my code:
FtpWebRequest request = (FtpWebRequest)WebRequest.Create(fileName);
request.Proxy = null;
request.UsePassive = false;
request.KeepAlive = !request.UsePassive;
request.Method = WebRequestMethods.Ftp.DeleteFile;
request.Credentials = new NetworkCredential(usr, pwd);
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
Debug.Print("Delete status: {0}", response.StatusDescription);
response.Close();
I tried to delete the file with async functions, but I got ‘Cannot send a content-body with this verb-type.’ error.
Can this be any faster and why is so slow?
Thanks!
What operating System are you running? My only thinking is that with Windows FileZilla may only be flagging a file for a delete and not actually deleting it. Once a file is flagged to be deleted it may be overwritten at some point when new data comes in. The “Instant” delete comes from setting the flag thats all. Your code i believe is not. If you are using windows you can see this because deleting a file of any size no matter how large is instant.