ComponentPro UltimateFtp

      Upload a directory

      Language Filter: AllSend comments on this topic to ComponentPro

      To upload an entire directory, pass the path to the directory ending with '\' to the Upload method.

      using (Ftp client = new Ftp())
      {
          // Connect to the FTP server. 
          client.Connect("localhost");
      
          // Authenticate. 
          client.Authenticate("test", "test");
      
          // Upload "data" directory to the server. 
          // The remote dir "/" will contain "/data" folder 
          client.Upload(@"c:\data\", "/");
      }
      

      Alternatively, you can use this Upload overload method with the includeBaseDirectory parameter set to true. The following code snippet shows how to upload an entire directory.

      using (Ftp client = new Ftp())
      {
          // Connect to the FTP server. 
          client.Connect("localhost");
      
          // Authenticate. 
          client.Authenticate("test", "test");
      
          // Upload "data" directory to the server. 
          // The remote dir "/" will contain "/data" folder 
          client.Upload(@"c:\data", true, null, "/", new TransferOptions());
      }