+1 vote
by (210 points)

Hi,

I am currently creating an application that periodically uploads a log file. There is just one problem that I am having.

Since the log file needs to get a diffferent name on the remote machine each time it gets uploaded, the current date and time is appended to the file name.

I just can't get Sftp.Upload() to upload a file with a different targetname then the source name. Is there something I am missing or is there no way to do this without creating a temporary copy of the file?

Thanks in advance,
Lars

Applies to: Rebex SFTP

1 Answer

0 votes
by (58.9k points)

Hi ljruiten,

you need to use the Sftp.PutFile method that will allow you to upload the file under whatever remote name you choose:

        Sftp sftp = new Sftp();
        sftp.Connect("server");
        sftp.Login("user", "password");

        sftp.PutFile(@"C:\localFolder\localFilename.txt", "remoteFileName.txt");

The Upload method is primarily meant for batch file transfers (transferring multiple files with one method call) and due to its nature it only accepts remote directory as an argument and not a complete remote path.

...