sshnet / sshnet/SSH.NET

How to symlink a file in the same directory

Open
#1,336 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
4.4k
Forks
993
Avg merge
9d 21h
Merged PRs (30d)
1

Description

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?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the relative-path behavior with SftpClient.SymbolicLink in the /exports layout described. Read GetCanonicalPath and SymbolicLink to determine how the target path is resolved, then verify the expected link destination and add a regression test if the behavior is confirmed as incorrect.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.