在c#winform中搜索文件 [英] Searching files in c# winform

查看:240
本文介绍了在c#winform中搜索文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试列出C的所有目录和文件:

I am trying to list all Directory and file of C:

I tryed with
Directory.GetDirectories(dir,"*",SearchOption.AllDirectories)



但它抛出错误


but it throwing error

System.UnauthorizedAccessException was unhandled
  Message=Access to the path 'c:\Config.Msi\' is denied.



i希望我的程序继续搜索,但需要验证的文件除外。


i want my program such that it continue its search except that files which required Authentication.

推荐答案

为避免这种情况,请不要使用 SearchOption.AllDirectories ,而是自己编写所有递归代码:

http://stackoverflow.com/a/172575 [ ^ ]
To avoid this, don't use SearchOption.AllDirectories, but write all the recursion code yourself:
http://stackoverflow.com/a/172575[^]


这篇关于在c#winform中搜索文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆