Hi namojainashis...,
You need to use the FtpWebRequest class.
FtpWebRequest Class
Refer below code.
HTML
<asp:Button ID="btnDelete" runat="server" OnClick="OnDelete" />
Namespaces
C#
using System.Net;
VB.Net
Imports System.Net
Code
C#
protected void OnDelete(object sender, EventArgs e)
{
string fileName = "fileName";
string FtpUrl = "ftp://yourserver.com/";
string ftpFolder = "foldername/";
string FtpserverIP = FtpUrl + ftpFolder + fileName;
FtpWebRequest request = (FtpWebRequest)WebRequest.Create(FtpserverIP);
request.Method = WebRequestMethods.Ftp.DeleteFile;
request.Credentials = new NetworkCredential("userid", "password");
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
ClientScript.RegisterClientScriptBlock(this.GetType(), "", "alert('" + response.StatusDescription + "')", true);
response.Close();
}
VB.Net
Protected Sub OnDelete(ByVal sender As Object, ByVal e As EventArgs)
Dim fileName As String = "fileName"
Dim FtpUrl As String = "ftp://yourserver.com/"
Dim ftpFolder As String = "foldername/"
Dim FtpserverIP As String = FtpUrl & ftpFolder & fileName
Dim request As FtpWebRequest = CType(WebRequest.Create(FtpserverIP), FtpWebRequest)
request.Method = WebRequestMethods.Ftp.DeleteFile
request.Credentials = New NetworkCredential("userid", "password")
Dim response As FtpWebResponse = CType(request.GetResponse(), FtpWebResponse)
ClientScript.RegisterClientScriptBlock(Me.[GetType](), "", "alert('" & response.StatusDescription & "')", True)
response.Close()
End Sub