I get an UnautorizedAccessException running this code:
string[] fileList = Directory.GetFiles(strDir, strExt);
The exception occurs in c:\users\username\appdata
How can I check if I have access permission (to list and read files) ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
First of all, I would manually check the permissions and see what blocks you and what doesn’t. I am using something like this to check for permissions (for copy file):
Also, there are some strange cases where a certain right on the folder changes the right for the files regardless of their individual permissions (will see if I can find what it is).