Hello,
I am attempting to add functionality to my VB.Net and ASP.Net program that allows a user to enter the name of a file (and its extension) in to a textbox and press on a delete button which will then delete the file from my FTP site.
Below is my code so far:
I have tried doing it with this code, but when I go back to the FTP site, the file still remains.
Any help and advice will be greatly appreciated.
Many Thanks,
Dan
I am attempting to add functionality to my VB.Net and ASP.Net program that allows a user to enter the name of a file (and its extension) in to a textbox and press on a delete button which will then delete the file from my FTP site.
Below is my code so far:
VB.NET:
Protected Sub Button6_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button6.Click
Dim ftp As FtpWebRequest = DirectCast(WebRequest.Create("[URL]ftp://xx.xx.x.xx/In/[/URL]" + TextBox2.Text), FtpWebRequest)
If TextBox2.Text = "" Then
MsgBox("A file needs to be selected!")
End If
If TextBox1.Text <> "" Then
Try
[URL="ftp://ftp.Credentials"]ftp.Credentials[/URL] = New System.Net.NetworkCredential("user", "password")
[URL="ftp://ftp.Method"]ftp.Method[/URL] = WebRequestMethods.Ftp.DeleteFile
Dim ftpResponse As FtpWebResponse = CType([URL="ftp://ftp.GetResponse"]ftp.GetResponse[/URL](), FtpWebResponse)
ftpResponse = [URL="ftp://ftp.GetResponse"]ftp.GetResponse[/URL]()
ftpResponse.Close()
Catch ex As Exception
End Try
End If
End Sub
I have tried doing it with this code, but when I go back to the FTP site, the file still remains.
Any help and advice will be greatly appreciated.
Many Thanks,
Dan