Check Connection to the FTP Server

Jul 31, 2008 at 3:21 PM
Edited Jul 31, 2008 at 3:36 PM
I have found it useful to check if the credentials will allow you to logon before attempting any action on the server. Here is the additional method which may be usefully included in a later release.... 

Public Function CheckLogon() As Boolean

Dim ftp As Net.FtpWebRequest = GetRequest(Hostname)
ftp.Method = Net.WebRequestMethods.Ftp.PrintWorkingDirectory

    'get response but ignore it
    Dim str As String = GetStringResponse(ftp)
Catch ex As WebException
    If ex.Status = WebExceptionStatus.Success Then
        Return True
        Return False
    End If
Catch ex As Exception
End Try

nd Function











Aug 1, 2008 at 11:24 AM
Good suggestion CodeSurfer.