PowerTCP FTP for .NET
Connect(String) Method
Example 



The hostname or IP address of the server.
Connects to the specified FTP server using other parameters specified in Session.
Syntax
Public Overloads Function Connect( _
   ByVal hostNameOrAddress As String _
) As Response
Dim instance As Ftp
Dim hostNameOrAddress As String
Dim value As Response
 
value = instance.Connect(hostNameOrAddress)
public Response Connect( 
   string hostNameOrAddress
)
public:
Response^ Connect( 
   String^ hostNameOrAddress
) 

Parameters

hostNameOrAddress
The hostname or IP address of the server.

Return Value

The server greeting.
Remarks

Sets Session.RemoteEndPoint.HostNameOrAddress to the provided value and calls Connect.

Authenticate or Authenticate(String,String) must be called after this method if a login is desired. Otherwise, the user must send their own custom commands to authenticate with the server.

SSL encryption is negotiated if Session.Security.EncryptControl is EncryptControl.Implicit.

Example
This example demonstrates using the FTP control to retrieve a file using the FTP GET command.
private void button1_Click(object sender, EventArgs e)
{
    //Connect to the FTP Server.
    ftp1.Connect(myServer);

    //Login with user credentials
    ftp1.Authenticate(myUsername, myPassword);

    //Retrieve a file.
    ftp1.Get("testfile.txt", Path.Combine(myLocalDirectory, "testfile.txt"), Synchronize.Off);

    //Close the connection.
    ftp1.Close();
}
Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles button1.Click
    'Connect to the FTP Server.
    ftp1.Connect(myServer)

    'Login with user credentials
    ftp1.Authenticate(myUsername, myPassword)

    'Retrieve a file.
    ftp1.Get("testfile.txt", Path.Combine(myLocalDirectory, "testfile.txt"), Synchronize.Off)

    'Close the connection.
    ftp1.Close()
End Sub
See Also

Reference

Ftp Class
Ftp Members
Overload List


PowerTCP FTP for .NET Documentation Version 6.1
© 2023 Dart Communications. All Rights Reserved.
Send comments on this topic