@
geelaw 我有一个问题想请教一下,如果遍历文件夹的时候,碰到那种文件夹里面快捷方式 /链接引用文件夹本身的情况,有什么比较好的最佳实践么?
比如 D:/test/mydir/下面有个 mydir.lnk 是指向 D:/test/mydir/本身的。
我在微软官方网站上找到了一些描述这方面的资料:
https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/file-system/how-to-iterate-through-a-directory-tree中间有一段 Note:
NTFS file systems can contain reparse points in the form of junction points, symbolic links, and hard links. .NET methods such as GetFiles and GetDirectories will not return any subdirectories under a reparse point. This behavior guards against the risk of entering into an infinite loop when two reparse points refer to each other. In general, you should use extreme caution when you deal with reparse points to ensure that you do not unintentionally modify or delete files. If you require precise control over reparse points, use platform invoke or native code to call the appropriate Win32 file system methods directly.
最近做这方面的开发,发现涉及到文件系统的话,要考虑的东西太多了,Permission ,Shared Folder ,Shortcut 。。。