Reputation: 33
I tried to get access information of 'current user' folder. But this code always return "method failed with unexpected error code 3, InvailedOperationException".
Here is my code
string CurrentUserName = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
var Info = new DirectoryInfo("C:\\users\\"+ CurrentUserName);
var Security = Info.GetAccessControl();
Upvotes: 1
Views: 3797
Reputation: 33
Thank you Blorgbeard. Here is the alternative code what you told. It works perfectly.
string CurrentUserName = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
var Info = new DirectoryInfo(CurrentUserName);
var Security = Info.GetAccessControl();
Upvotes: 2