简体   繁体   中英

UnauthorizedAccessException when using Directory.GetFiles

In the application I am writing, the user has the ability to add some folder to search for some files recursively.

The problem is the files he wants to add to the app might be stored in the base drive like K:. So if he add this drive directly, I get an exception.

Or if he adds C:\\, then I get UnauthorizedAccessException where it says:

Access to the path 'C:\\System Volume Information' is denied.

How can I just scan where I can scan? And give the ability to scan another non-system drive fully (all directories)?

捕获异常,忽略它,然后转到下一个目录。

Why does this not work for me then. I try/catch the unauthorizedAccessException and it still just stops the program.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM