En .NET, creo que puedo determinar si un archivo es un enlace simbólico llamando a System.IO.File.GetAttributes() y buscando el bit ReparsePoint. como el siguiente:En .NET, ¿cómo obtener el destino de un enlace simbólico (o punto de análisis)?
var a = System.IO.File.GetAttributes(fileName);
if ((a & FileAttributes.ReparsePoint) != 0)
{
// it's a symlink
}
¿Cómo puedo obtener el objetivo del enlace simbólico, en este caso?
PS: Sé cómo crear un enlace simbólico. Requiere P/Invoke:
[Interop.DllImport("kernel32.dll", EntryPoint="CreateSymbolicLinkW", CharSet=Interop.CharSet.Unicode)]
public static extern int CreateSymbolicLink(string lpSymlinkFileName, string lpTargetFileName, int dwFlags);
Este me llevó al código fuente de las Extensiones Comunitarias Powershell (PSCX), que tiene un buen código para manejar ReparsePoints. – Cheeso