1

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);
sftp.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 :-)

grady
  • 12,281
  • 28
  • 71
  • 110
  • 1
    You've not actually said what's wrong - presumably you're saying the file is not saved? – tomfanning Mar 25 '11 at 08:55
  • Yes, it does not appear on c:\ with name test.txt. No error is thrown..though and debugging shows no problems as well. – grady Mar 25 '11 at 08:57
  • 2
    I figured it out! The way i had it was correct, the code had no wirting privs for the local path! Thanks anyway guys! – grady Mar 25 '11 at 09:13
  • hi grady, how did you solve it, please explain with more details, I have the same problem :( – user741319 Nov 09 '12 at 22:29

1 Answers1

4

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();
tomfanning
  • 9,552
  • 4
  • 50
  • 78