Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check if a file is real or a symbolic link

Tags:

c#

symlink

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.

like image 248
mattdwen Avatar asked Sep 28 '09 02:09

mattdwen


People also ask

How do you know if a link is hard or symbolic?

A simple way to see the difference between a hard link and a symbolic link is through a simple example. A hard link to a file will point to the place where the file is stored, or the inode of that file. A symbolic link will point to the actual file itself.

How do you check if a file is a symlink Python?

islink() method in Python is used to check whether the given path represents an existing directory entry that is a symbolic link or not. Note: If symbolic links are not supported by the Python runtime then os. path. islink() method always returns False.

Are symbolic links regular files?

Symbolic links are different from hard links. Hard links do not link paths on different volumes or file systems, whereas symbolic links may point to any file or directory irrespective of the volumes on which the link and target reside.


1 Answers

private bool IsSymbolic(string path) {     FileInfo pathInfo = new FileInfo(path);     return pathInfo.Attributes.HasFlag(FileAttributes.ReparsePoint); } 
like image 124
zurfyx Avatar answered Sep 28 '22 13:09

zurfyx