You will probably not be able to copy the file directly. For details why, see:
In an SFTP session is it possible to copy one remote file to another location on same remote SFTP server?
If you have a shell access, you can of course execute cp
command using a shell session.
See How to run commands on SSH server in C#?
The only reliably working way to duplicate remote file over SFTP is to download and re-upload the file.
The easiest way to do that (without creating a temporary local file) is:
SftpClient client = new SftpClient("example.com", "username", "password");
client.Connect();
using (Stream sourceStream = client.OpenRead("/source/path/file.dat"))
using (Stream destStream = client.Create("/dest/path/file.dat"))
{
sourceStream.CopyTo(destStream);
}
But I'm aware that this is not what you are after.