Archived Forum Post

Index of archived forum posts


SFTP Delete existing file

Sep 03 '14 at 15:47

I am working on ChillKat Sftp, I need to delete an existing file in the server. I have done this in the regular FTPWebRequest using System.Net.WebRequestMethods.Ftp.DeleteFile.

Do ChillKat supports any inbuilt class for deleting the exitsting file.

 Protected _ftpWebRequest As FtpWebRequest
        Private _userId As String = ""
        Private _domain As String = ""
        Private _uri As String = ""
        Private _password As String = ""
        Private _useBinary As Boolean = False

' Assume that there are correct values for the above variables. Function is working fine for FtpWebRequest Method.

    ' Delete Exiting File
     Public Function DeleteFile(ByVal fileName As String) As Boolean
                    _ftpWebRequest = CType(WebRequest.Create(_uri & fileName), FtpWebRequest)
                    _ftpWebRequest.Credentials = New System.Net.NetworkCredential(_userId, _password, _domain)
                    _ftpWebRequest.Method = WebRequestMethods.Ftp.DeleteFile

                    Dim prxy As New System.Net.WebProxy()
                    prxy.BypassProxyOnLocal = True
                    _ftpWebRequest.Proxy = prxy

                    Using response As FtpWebResponse = CType(_ftpWebRequest.GetResponse(), FtpWebResponse)
                    End Using

                Catch ex As Exception
                    Throw New Exception(ex.Message)
                End Try

                Return True
            End Function

Accepted Answer

The method is named RemoveFile. See the online reference documentation...