• Loading...
ComponentPro UltimateSftp

Download a remote file to another file system

Language Filter: AllSend comments on this topic to ComponentPro

To download a file from an SFTP server to another file system, use the CopyTo methods.

The following example demonstrates how to connect to FTP and SFTP servers, and use the CopyTo method to directly copy a file from the SFTP file system to the FTP file system.

If you need to download files and directories to a ZIP file, see the topic Downloading files and directories to a ZIP file.
using System;
using System.Collections.Generic;
using System.Text;
using ComponentPro.IO;
using ComponentPro.Net;


// Connect to an FTP file system.
Ftp ftpsys = new Ftp();
ftpsys.Connect("", 21);
ftpsys.Authenticate("test", "test");

// Connect to an SFTP file system.
Sftp sftp = new Sftp();
sftp.Connect("", 2222);
sftp.Authenticate("test", "test");

// Copy 'my blog on SFTP file system.txt' file from the SFTP file system to the FTP file system.
sftp.CopyTo("my blog on SFTP file system.txt", ftpsys, "blog.txt");