Public Function CheckIfFtpFileExists(ByVal Url As String, ByVal User As String, ByVal Pass As String) As Boolean
Dim request As FtpWebRequest = WebRequest.Create(Url)
request.Credentials = New NetworkCredential(User, Pass)
request.Method = WebRequestMethods.Ftp.GetFileSize
Try
Dim response As FtpWebResponse = request.GetResponse()
Catch ex As WebException
Dim response As FtpWebResponse = ex.Response
If FtpStatusCode.ActionNotTakenFileUnavailable = response.StatusCode Then
Return False 'non esiste
End If
End Try
Return True 'esiste
End Function