从后面的符号链接中防止IO.GetDirectories()

Clé*_*ent 3 .net linux io mono symlink

在使用mono将.net应用程序移植到Linux时,我注意到它IO.GetDirectories在Linux上实现了以下符号链接(当我的程序到达时问题变得明显/home/clement/svn/obrowser/tutorial/distrib/tutorial/distrib/tutorial/distrib/tutorial/distrib/tutorial/distrib/tutorial/distrib/tutorial/distrib/tutorial/distrib/tutorial/distrib).

我在mono的网站上找不到关于这种行为的任何文档,除了一个小小的论坛帖子之外.

您是否知道防止IO.GetDirectories遵循符号链接的解决方法?

小智 5

您可以检查File.GetAttributes,符号链接将具有ReparsePoint属性,我使用Windows符号链接和ubuntu 10.10进行了测试.

这不会阻止GetDirectories递归枚举,但你必须自己进行递归.

如果您不需要跨平台支持,则可能需要查看Mono.Unix.UnixDirectoryInfo.