Directly downloading files to a ZIP file
All file system classes, including SFTP, FTP, and ZIP, base on the the unified FileSystem base class, making it easy to transfer files and directories directly from one system to another. By creating or opening a ZIP file and call the DownloadFiles method of the Ftp class, you can achieve the goal in an elegant way. Moreover, the code you have written for FTP system can also be used for the Sftp and Scp classes of the Ultimate SFTP component. The following code demonstrates how to achieve the goal with the Ftp class and the Ultimate ZIP component:
// Create a ZIP file.
Zip zipFile = new Zip(@"c:\test.zip");
Ftp ftp = new Ftp();
// Connect to the FTP server.
ftp.Connect("atp-inc.net", 21);
// Authenticate.
ftp.Authenticate("test", "test");
// Create a new instance of the TransferOptions class.
// There are many advanced option in the TransferOptions class such as Recursive, allowing empty directory creation, etc.
TransferOptions opt = new TransferOptions();
// Download files to the ZIP file directly.
ftp.DownloadFiles("*.cs;*.vb;*.exe", (IFileInfo[])null, zipFile, "", opt);
ftp.Disconnect();
zipFile.Close();
Click here to download the Ultimate FTP Component for .NET, or here to download the .NET CF version.