Listing all files in a drive other than my system drive throws an UnauthorizedAccessException
.
How can I solve this problem?
Is there a way to grant my application the access it needs?
My code:
Directory.GetFiles("S:\\", ...)
Listing all files in a drive other than my system drive throws an UnauthorizedAccessException
.
How can I solve this problem?
Is there a way to grant my application the access it needs?
Directory.GetFiles("S:\\", ...)
Are you allowed to access the drive? Can the program access the drive when it's not run from Visual Studio? Are restrictive permissions defined in the project's Security page ("Security Page, Project Designer")?
I solved the problem. Not really but at least the source.
It was the SearchOption.AllDirectories option that caused the exception.
But when I just list the immediate files using Directories.GetFiles, it works.
This is good enough for me.
Any way to solve the recursive listing problem?