Esraa_92 Esraa_92 - 1 year ago 126 Question

How can I remove an image from FTP

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("" & 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?

Answer Source

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()
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download