想要避免系统卷信息文件夹路径 [英] want to avoid System Volume Information folder path
本文介绍了想要避免系统卷信息文件夹路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好.....
我想搜索目录中的所有子目录
我的代码是
Hi Everyone.....
I want to search all sub directory within a directory
my code is
DirectoryInfo di = new DirectoryInfo(Search_Path);
DirectoryInfo[] direcorries = di.GetDirectories("*.*", SearchOption.AllDirectories);
但是这里我有一个例外
but here i got an exception
exception {"Access to the path 'F:\\System Volume Information\\' is denied."} System.Exception {System.UnauthorizedAccessException}
但是如果我用
but if i used
DirectoryInfo di = new DirectoryInfo(dir);
DirectoryInfo[] direcorries = di.GetDirectories("*.*", SearchOption.TopDirectoryOnly);
那么它不会通过异常....
为什么会这样?
我想避免使用此系统卷信息"文件夹.我该怎么做??
then it does not through an exception ....
why this happens?
I want to avoid this System Volume Information folder. How can i do that ??
推荐答案
AFAIK,使用任何直接选项都很难通过代码跳过它们.我寻找了类似的东西(如果之前已经讨论过),并通过SA找到了以下答案: ^ ]
看起来,您没有直接方法可以通过任何设置浏览所有跳过的不可访问文件夹.您需要通过try-catch处理这些特定的错误,然后继续.这不是一个好方法,但是看起来可能是一种寻求帮助的方法.
AFAIK, it would be difficult to skip them through code using any direct option. I looked for something similar if already discussed earlier and found this answer by SA: How to display accessible files only and skip inaccessible file?[^]
It looks like, you don''t have a direct way to go through all skipping inaccessible folders by any setting. You need to handle those specific errors in a try-catch and move on. Not a good way but looks like the possible way to get you seek.
这篇关于想要避免系统卷信息文件夹路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文