ComponentPro UltimateFtp

      Connect to an FTP server

      Language Filter: AllSend comments on this topic to ComponentPro

      In order to use the Ftp and other classes, you have to add references to ComponentPro.Ftp.dll, ComponentPro.Common.dll, ComponentPro.Network.dll, and ComponentPro.FileSystem.dll assemblies to your project.

      Now you can use FTP classes to connect and authenticate to the desired FTP server.

      To authenticate to an FTP server, you can simply perform the following steps

      1. Add using directives to your code to create aliases for existing namespaces and avoid having to type the fully qualified type names. The code looks similar to the following:
        using ComponentPro.Net;
        
      2. Create a new instance of the Ftp class.
      3. Now you can connect to the FTP server with Connect methods. The code looks similar to the following:
        // Create a new class instance.
        Ftp client = new Ftp();
        
        // Connect to the FTP server.
        client.Connect("myserver");
        
        // Or you can specify the FTP port with 
        // client.Connect("myserver", 21);
        
      4. Use your user name and password to login with one of Authenticate methods.  The code looks similar to the following:
        // Authenticate.
        client.Authenticate("userName", "password");
        
      5. Do your work like browsing directories, uploading file, downloading file,etc.  The code looks similar to the following:
        client.DownloadFile("/my remote file.dat", "my local file");
        
      6. After completing your work, call the Disconnect method to close the FTP session. 

      Final example code

      using ComponentPro.Net;
      
      ...
      
      // Create a new class instance.
      Ftp client = new Ftp();
      
      // Connect to the FTP server.
      client.Connect("myserver");
      
      // Or you can specify the FTP port with 
      // client.Connect("myserver", 21); 
       
      // Authenticate.
      client.Authenticate("userName", "password");
      
      // Do something here...
      client.DownloadFile("/my remote file.dat", "my local file");
      
      // Disconnect.
      client.Disconnect();