Click here to Skip to main content
15,885,985 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Error:
C#
Access to the path 'C:\Users\.NET v2.0' is denied.


What I have tried:

String[] allfiles = null;
allfiles = System.IO.Directory.GetFiles("C://Users", "*.*", System.IO.SearchOption.AllDirectories);
Posted
Updated 12-Apr-16 22:16pm
Comments
VR Karthikeyan 13-Apr-16 3:33am    
Run your application as administrator.

Easy as this
string[] folders = System.IO.Directory.GetDirectories(@"C:\My Sample Path\","*", System.IO.SearchOption.AllDirectories);

If you get Access denied message, run your visual studio as administrator.

Thanks & Regard
SHAM :)
 
Share this answer
 
Hi
you have to provide the full path for the folder from where you are looking the files.

C#
String[] allfiles = null;
            allfiles = System.IO.Directory.GetFiles("C://Users/.NET v2.0", "*.*", System.IO.SearchOption.AllDirectories);



As in users folder there are few folder on which you don't have access, that's why you are getting this error or you can run your VS as administrator.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900