peteraritchie / LongPath

drop-in library to support long paths in .NET
GNU Lesser General Public License v3.0
112 stars 43 forks source link

Wrong behavior of Directory.Delete for Reparse Points #28

Closed SchreinerK closed 8 years ago

SchreinerK commented 9 years ago

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 commented 9 years ago

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

peteraritchie commented 8 years ago

Fixed by a5fa4612671c88f337abb579177243f95ad18a29