Directory.Delete(string,bool) follows the reparse point, which is wrong.
System.IO.Directory.Delete:
"The behavior of this method differs slightly when deleting a directory that contains a reparse point, such as a symbolic link or a mount point. If the reparse point is a directory, such as a mount point, it is unmounted and the mount point is deleted. This method does not recurse through the reparse point. If the reparse point is a symbolic link to a file, the reparse point is deleted and not the target of the symbolic link. " https://msdn.microsoft.com/en-us/library/fxeahc5f%28v=vs.110%29.aspx
Fast fix would be:
public static void Delete(string path, bool recursive) {
var isReparsePoint=(new DirectoryInfo(path).Attributes & System.IO.FileAttributes.ReparsePoint) != 0;
if (isReparsePoint) { Delete(path); return;}
...
}
And by the way parameter "recursive" is never used!
Directory.Delete(string,bool) follows the reparse point, which is wrong.
System.IO.Directory.Delete: "The behavior of this method differs slightly when deleting a directory that contains a reparse point, such as a symbolic link or a mount point. If the reparse point is a directory, such as a mount point, it is unmounted and the mount point is deleted. This method does not recurse through the reparse point. If the reparse point is a symbolic link to a file, the reparse point is deleted and not the target of the symbolic link. " https://msdn.microsoft.com/en-us/library/fxeahc5f%28v=vs.110%29.aspx
Fast fix would be: public static void Delete(string path, bool recursive) { var isReparsePoint=(new DirectoryInfo(path).Attributes & System.IO.FileAttributes.ReparsePoint) != 0; if (isReparsePoint) { Delete(path); return;} ... }
And by the way parameter "recursive" is never used!