Use SharpSSH to download a file from a SFTP server?
I am using SharpSSH (http://www.tamirgal.com/blog/page/SharpSSH.aspx) to upload a file to some sftp server. This works nice. Now I want to download a file and I guess the Get method can be used for that. Thats my code:
Sftp sftp = new Sftp(ip, user, password);
sft开发者_开发问答p.Connect();
sftp.Get(pathOnSftpServer (/home/file.txt), localPathOnMyComputer (c:\test.txt));
sftp.Close();
The Get method has void as return type so I guess the file will be saved to what I specified in the 2nd parameter? Whats wrong with the above code? The file is not saved as c:\test.txt.
Thanks :-)
Your code won't compile as is. For starters it's missing quotes.
If you only have a single backslash, try sticking an extra backslash in where you have c:\test.txt
i.e. c:\test.txt
The \t
you have in there is being interpreted as a tab character.
Sftp sftp = new Sftp(ip, user, password);
sftp.Connect();
sftp.Get("/home/file.txt", "c:\\test.txt");
sftp.Close();
精彩评论