Ftp Object : Login Method |
Visual Basic |
---|
Public Sub Login( _ Optional ByVal RemoteName As String, _ Optional ByVal User As String, _ Optional ByVal Password As String, _ Optional ByVal Account As String, _ Optional ByVal RemotePort As Long = 0 _ ) |
If RemoteName is specified and State is not tcpClosed, then the existing session is immediately aborted.
If RemoteName is specified, then a connection is attempted. The State event fires if it succeeds; otherwise, the Error event fires.
If RemoteName is not specified and State is not tcpConnected, then a ptNotConnected error is generated. If RemoteName is not specified and State is tcpConnected, then a ftpReinitialize command is sent to prepare the server to authenticate again.
Once connected and ready to authenticate, the ftpUser, ftpPassword, and ftpAccount commands are sent to the server.
If Timeout is greater than 0, Login blocks until authentication is complete, an error occurs, or a ptTimeout error occurs. If Timeout is 0, Login immediately returns and the Progress event fires multiple times as each server reply is received.
This method may generate the following error code (refer to ErrorConstants for a complete list of error codes):
Private Sub Command1_Click() On Error GoTo OnError ' use intrinsic error handling Ftp1.Login "ftp.dart.com", "anonymous", "powertcp" If Ftp1.State = tcpConnected Then MsgBox "Connected!" Exit Sub OnError: ' Any error jumps here Debug.Print "Error #" + CStr(Err.Number) + ": " + Err.Description End Sub