Esraa_92 Esraa_92 - 3 months ago 28
Vb.net Question

How can I remove an image from FTP vb.net?

I looking for a code to remove images from FTP but does'nt work
I tried to use this code but not work for me:

Dim FTPRequest As System.Net.FtpWebRequest = DirectCast(System.Net.WebRequest.Create("ftp://myftpname.es/Html/images/" & imagename), System.Net.FtpWebRequest)
FTPRequest.Credentials = New System.Net.NetworkCredential("FTPUsername", "FTPPassword")
FTPRequest.Method = System.Net.WebRequestMethods.Ftp.DeleteFile
FTPRequest.UsePassive = True
FTPRequest.UseBinary = True
FTPRequest.KeepAlive = False


How can I remove images from ftp?
Thanks

Answer

this code not remove the image from the ftp

That's because you never actually execute it, you just initialize it. To issue a WebRequest, you need to get its response:

var response = FTPRequest.GetResponse()