0
我试图(没有太多的运气)搜索特定的文件,但只有它存在于特定的目录中。在特定目录中搜索文件C#
例如:假设我想要搜索test.txt
,但前提是它位于TestFolder的目录结构中(不必在TestFolder中,但必须位于TestFolder的子文件夹中)。 TestFolder的位置未知。
我试过这个,但是当它碰到一个没有访问权限的目录时就出错了。
string[] list = Directory.GetDirectories("c://", "TestFolder", SearchOption.AllDirectories);
虽然是找到目录,然后在该目录中搜索该文件。
任何帮助将不胜感激!
HTTP:/ /stackoverflow.com/questions/172544/ignore-folders-files-when-directory-getfiles-is-denied-access和http://stackoverflow.com/questions/1393178/unauthorizedaccessexception-cannot-resolve-directory-getfiles-failure几乎是同样好的解释。 –