Esraa_92 Esraa_92 - 1 month ago 7x 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?


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()