Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong behavior of Directory.Delete for Reparse Points #28

Closed
SchreinerK opened this issue Aug 19, 2015 · 2 comments
Closed

Wrong behavior of Directory.Delete for Reparse Points #28

SchreinerK opened this issue Aug 19, 2015 · 2 comments

Comments

@SchreinerK
Copy link
Contributor

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!

@peteraritchie
Copy link
Owner

Looks like it would make a great pull request! :)

@peteraritchie
Copy link
Owner

Fixed by a5fa461

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants