• Loading...
ComponentPro UltimateSftp

Upload data from a file on another file system

Language Filter: AllSend comments on this topic to ComponentPro

To upload a file from another file system to an SFTP server, simply 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 FTP file system to the SFTP file system.

If you need to upload files and directories within a ZIP file to the SFTP server, see the topic Uploading files and directories within a ZIP file to an SFTP server.
using ComponentPro.Net;

...

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

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

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

ftpsys.Disconnect();
sftp.Disconnect();