In C#, I need to find the actual path of a file/directory in Linux that might be on the other side of a symlink.
I have found the solution to this on Windows at How to obtain the target of a symbolic link (or Reparse Point) using .Net?, but that for fairly obvious reasons won't work on Linux. I could call out to readlink, but I may need to do this a lot, and I'd hate to spend all of that time handling external processes.
I'd like something like this:
string GetFinalPathName(string inputPath);
If the symlink is something like:
/link -> /actual/path
And I call GetFinalPathName("/link/myfile.txt")
it should return "/actual/path/myfile.txt".
How can I find the target of a Linux Symlink in C#?