>>Does anyone have any suggestions for an SFTP client for .NET?
>>
>>I've seen a few, but would appreciated any recommendations.
>
>Here's the one I use:
https://github.com/sshnet/SSH.NET>
>Code sample (I used this code to download a file from the FTP server and store it on my local machine):
>
>
> class Program
> {
> static void Main(string[] args)
> {
> // http://www.csidata.com/?page_id=2828
> // http://stackoverflow.com/questions/23703040/download-files-from-sftp-with-ssh-net-library
>
> //http://www.jokecamp.com/blog/connecting-to-sftp-with-key-file-and-password-using-ssh-net/
> string keyFile = @"c:/path-to-your-ppk-file/blah_private.ppk_openssh";
> string passPhrase = "your-passphrase";
> PrivateKeyFile privateKeyFile = new PrivateKeyFile(keyFile, passPhrase);
>
> string host = @"123.123.123.123";
> int port = 22;
> string username = "root-user-name";
> string remoteFilename = @"/root/path-to-file/filename-to-download.ext";
>
> //DateTime in Filename from here: http://www.dotnetperls.com/filename-datetime
>
> string localFilename = string.Format("Development-{0:yyyy-MM-dd_hh-mm-ss-tt}.ext", DateTime.Now);
> localFilename = @"c:\users\Billy\download-path\" + localFilename;
>
> //using (var sftp = new SftpClient(host, port, username, password))
>
> using (var sftp = new SftpClient(host, port, username, privateKeyFile))
> {
> sftp.Connect();
>
> using (var file = File.OpenWrite(localFilename))
> {
> sftp.DownloadFile(remoteFilename, file);
> }
>
> sftp.Disconnect();
> }
>
> }
> }
>
Thank you, Matt
I'll take a look
Anyone who does not go overboard- deserves to.
Malcolm Forbes, Sr.