ComponentPro UltimateFtp

      Upload files

      Language Filter: AllSend comments on this topic to ComponentPro

      To upload multiple files (e.g. all ".dat" files), use the Upload methods. The most used Upload method overload just needs two parameters. The first one is the path to the local directory and the second one is the path to the remote directory.

      using System;
      using ComponentPro.IO;
      using ComponentPro.Net;
      // Create a new class instance.
      Ftp client = new Ftp();
      // Connect to the FTP server.
      // Authenticate.
      client.Authenticate("test", "test");
      // ... 
      // Upload all files and subdirectories from local folder 'c:\temp' to the remote dir '/temp'
      client.Upload("c:\\temp", "/temp");
      // Upload all directories, subdirectories, and files that match the specified search pattern from local folder 'c:\myfolder2' to remote folder '/myfolder2'.
      client.Upload("c:\\myfolder2", "/myfolder2", "*.cs");
      // or you can simply put wildcard masks in the source path, our component will automatically parse it. 
      // upload all *.css files from local folder 'c:\myfolder2' to remote folder '/myfolder2'.
      client.Upload("c:\\myfolder2\\*.css", "/myfolder2");
      // Upload *.cs and *.vb files from local folder 'c:\myfolder2' to remote folder '/myfolder2'.
      client.Upload("c:\\myfolder2\\*.cs;*.vb", "/myfolder2");
      // ... 
      // Disconnect.
      To understand more about wildcard masks and search criterion, see this topic.

      Upload specific files and directories

      To upload just some specific files and directories, use the Upload method overloads that have localFilesToTransfer or sourceFilesToTransfer parameter like this Upload overload.

      using (Ftp ftp = new Ftp())
          // Connect to the FTP server. 
          // Authenticate. 
          ftp.Authenticate("test", "test");
          string[] filesAndFoldersToUpload = new string[]
              filesAndFoldersToUpload, // List of files and folders to upload. 
              "/dest", // The remote directory on the FTP server. 
              new TransferOptions()