ComponentPro UltimateSftp

      Transfer queue

      Language Filter: AllSend comments on this topic to ComponentPro

      Are you looking for a component that has the capability to add files and directories to a queue and start, stop or pause the queue any time? The TransferQueue class is designed to do that job. The free LionFTP client is an example of how a WinForms application makes use of that class.

      That class also allows you to add files to transfer, sort file list, set item priority on-the-fly. It also lets you change the number of threads used to transfer files while the queue is still in process, start, pause and resume the queue.

      // Create a new instance of the Sftp class. 
      using (Sftp client = new Sftp())
          // Connect to the server. 
          // Authenticate the user 
          client.Authenticate(userName, password);
          // Initialize a queue with 5 threads. 
          TransferQueue queue = new TransferQueue(5);
          // Add items to the queue 
          queue.Add(DiskFileSystem.Default.CreateFileInfo(@"C:\data\folder1"), client.CreateFileInfo("/data/folder1"), false, null, 0);
          queue.Add(DiskFileSystem.Default.CreateFileInfo(@"C:\data\folder2"), client.CreateFileInfo("/data/folder2"), false, null, 0);
          queue.Add(DiskFileSystem.Default.CreateFileInfo(@"C:\data\file1"), client.CreateFileInfo("/data/file1"), false, null, 0);
          // Start the queue. 
          // It immediately returns control to the caller's process. 
          // ... 
          // Here we can add more items to the queue while it's in progress 
          queue.Add(DiskFileSystem.Default.CreateFileInfo(@"C:\data\folder3"), client.CreateFileInfo("/data/folder3"), false, null, 0);
          // ... 
          // or we can change the number of threads. 
          // e.g. use 5 more threads -> 10 threads. 
          queue.Threads = 10;
          // ... 
          // the queue can be paused. 
          // ... 
          // and then resumed 
          // ... 
          // we can also wait until it completes.