Set filename on upload

0 votes
asked Apr 19 by Almis (220 points)

Hello,

I'm trying to upload a file but I want to upload it using a different target name, the reason I want to use a different name is that there is a file system listener that automatically pickups files with a specific extension. I was using FluentFtp, then switch to SSH.net and now I'm trying this library. Both previous libraries supported this functionality but from what I see you only allow setting directory path. Is there any way to achieve what I want?

Thanks.

Applies to: Rebex SFTP

1 Answer

+1 vote
answered Apr 20 by Lukas Pokorny (121,790 points)
selected Apr 20 by Almis
 
Best answer

Hello, the PutFile method makes it possible to specify the target name:

// connect to a server
var sftp = new Rebex.Net.Sftp();
sftp.Connect(hostname);

// verify server's fingerprint here

// authenticate
sftp.Login(username, password);

// upload a local file to server
sftp.PutFile(@"C:\MyData\file.txt", "/MyData/file.txt");
...