Establishing a Connection  
 

In order to transfer files or use the various file management methods, it is necessary to establish a connection to the server. This is done by calling the Connect method and checking the return value to make sure that the connection was successful. To establish that connection, certain information is required. This includes:

  • The host name or IP address of the server that you wish to connect to. This information may be specified by either setting the HostName property, or by passing the host name as an argument to the Connect method. For example, ftp.microsoft.com is a valid host name.
     
  • The port number of the server that you're connecting to. This can be specified by setting the RemotePort property or passing the port number as an argument to the Connect method. In most cases, the default port number should be used and it is not necessary to specify the port number in your application. However, for servers that are configured to use non-standard port numbers, that information must be provided. Setting the RemotePort property to a value of zero specifies that the default port number appropriate for that protocol should be used.
     
  • If a secure, encrypted connection is required, then the Secure property should be set to True. A secure server is one that supports the SSL (Secure Sockets Layer) protocol, the TLS (Transport Layer Security) protocol or the SSH (Secure Shell) protocol.

In addition, FTP connections almost always require a user name and password. If neither is specified, the control will attempt an anonymous login. Not all FTP servers support anonymous logins and an error may be returned indicating that the username or password is invalid. In rarer circumstances, an account name may also be required. HTTP connections rarely require a username and password for downloads, although that information may be required to upload files to the server.

Either FTP or HTTP servers may be accessible only through a proxy server in certain circumstances. In those circumstances, a set of properties related to proxies must be specified before connecting. Please see the Technical Reference for further details.