[Mono-list] Hard linking
jonpryor at vt.edu
Tue Sep 2 13:19:48 EDT 2008
On Tue, 2008-09-02 at 07:30 -0700, Magikat wrote:
> Could anyone tell me if hard-linking on both Linux and Windows is supported
> under the .Net Framework.
As far as I'm aware, symbolic links and hard links are NOT supported as
distinct entities under .NET. That is, you can read a hard link or
symbolic link normally, but there is no way to determine that the file
is a hard link or symbolic link from within .NET.
> If not, could you perhaps point to some information that might help writing
> something to help with hard-linking in C#.
On Mono/Linux, you can use the various Mono.Unix classes in
UnixFileSystemInfo e =
// file is a symbolic link
else if (e.IsRegularFile && e.LinkCount > 1)
// file is a hard link
Or you can use Mono.Unix.Native.Syscall for the ~actual POSIX APIs.
This doesn't work for Win32, though, so for Win32 support you'd need to
P/Invoke to the corresponding Win32 APIs, such as CreateHardLink() 
and CreateSymbolicLink() .
More information about the Mono-list