views:

159

answers:

2

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:\\", ...)
+1  A: 

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")?

ChrisW
Yes, I enabled click once security > full trust app. Is it enough?
Joan Venge
A: 

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?

Joan Venge