public class TransferQueue : Transferrer, ITraceSource
Shows how to use the TransferQueue class to add files/directories to the transfer list and start the queue.
using ComponentPro.IO; using ComponentPro.Net; ... // Create a new instance of the Ftp class. using (Ftp client = new Ftp()) { // Connect to the server. client.Connect(serverName); // 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. queue.Start(false); // ... // 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. queue.Stop(); // ... // and then resumed queue.Start(true); // ... // we can also wait until it completes. queue.Wait(true); }
Shows how to use the TransferQueue class to add files/directories to the transfer list and start the queue.
using ComponentPro.IO; using ComponentPro.Net; ... // Create a new instance of the Sftp class. using (Sftp client = new Sftp()) { // Connect to the server. client.Connect(serverName); // 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. queue.Start(false); // ... // 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. queue.Stop(); // ... // and then resumed queue.Start(true); // ... // we can also wait until it completes. queue.Wait(true); }