❔ Hardlink in Linux .NET 6.0
Dose anyone have a solution or guide to tell me how to essentially ln from within a .NET 6.0 console program ?
If I have to spawn ln I will but I'd rather achieve it without that if possible.
4 Replies
You'll need to p/invoke something native. Possibly libc's
link
. You can run through an example like https://github.com/ProfessionalCSharp/ProfessionalCSharp2021/blob/main/5_More/PInvoke/PInvokeSampleLib/Linux/LinuxNativeMethods.cs
Since you're on .NET 6, you won't be able to use [LibraryImport]
. You'll need to use the older [DllImport]
.
There are probably other examples on GitHub if you search DllImport libc link
and filter to C# if necessary.
(Also verify that the docs state it creates a hard link and not a symbolic link.)
This seems to work...
oh nice, thank you. I will look at that now 🙂
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.