Public Shared Function DeleteFileOnServer(ByVal serverUri As Uri) As Boolean
' The serverUri parameter should use the ftp:// scheme.
' It contains the name of the server file that is to be deleted.
' Example: ftp://contoso.com/someFile.txt.
'
If serverUri.Scheme <> Uri.UriSchemeFtp Then
Return False
End If
' Get the object used to communicate with the server.
Dim request As FtpWebRequest = CType(WebRequest.Create(serverUri), FtpWebRequest)
request.Method = WebRequestMethods.Ftp.DeleteFile
Dim response As FtpWebResponse = CType(request.GetResponse(), FtpWebResponse)
Console.WriteLine("Delete status: {0}", response.StatusDescription)
response.Close()
Return True
End Function