Check if a file is real or a symbolic link

mattdwen picture mattdwen · Sep 28, 2009 · Viewed 26.4k times · Source

Is there a way to tell using C# if a file is real or a symbolic link?

I've dug through the MSDN W32 docs, and can't find anything for checking this. I'm using CreateSymbolicLink from here, and it's working fine.

Answer

zurfyx picture zurfyx · Oct 20, 2014
private bool IsSymbolic(string path)
{
    FileInfo pathInfo = new FileInfo(path);
    return pathInfo.Attributes.HasFlag(FileAttributes.ReparsePoint);
}