UnauthorizedAccessException when using Directory.GetFiles

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

The problem is that the files that he wants to add to the application can be stored in a basic drive, such as K :. Therefore, if he adds this disk directly, I get an exception.

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

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

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

+3
source share
3

, .

+5

. / unauthorizedAccessException .

+1

See the following link for clarification: http://msdn.microsoft.com/en-us/library/bb513869.aspx

+1
source

Source: https://habr.com/ru/post/1714320/


All Articles