sshnet / SSH.NET

SSH.NET is a Secure Shell (SSH) library for .NET, optimized for parallelism.
http://sshnet.github.io/SSH.NET/
MIT License
3.88k stars 917 forks source link

How to symlink a file in the same directory #1336

Open axelgenus opened 4 months ago

axelgenus commented 4 months ago

I am using SSH.NET version 2024.0.0 (just upgraded).

I need to create a symlink to a file which is on the same folder with SftpClient.

The remote folder structure is pretty simple:

/
/exports
/exports/20240201.log
[...]
/exports/20240221.log
/exports/20240222.log
/exports/latest.log

latest.log needs point to the latest log (20240222.log in this case).

I tried using sftpClient.SymbolicLink("20240222.log", "latest.log") but GetCanonicalPath changes the path, resulting in a link to /20240222.log (which is wrong because it points to the root directory). I tried changing the working directory to "exports" but that results in a link to /exports/20240222.log (which is also wrong because the file is in the same folder).

Is this feasible?