I have user call 'amsd' which path is 'C:\\Users\\amsd'. After that I changed the user name to 'other'. But the path is not changed, its name is same as before. But now what I am trying to do is, I need to access that path from my current user. Lets assume that I know only the user name (other) not the path variable name (c:\\users\\amsd). But I need to access that path. How can I do that. I tried System.Environment.GetEnvironmentVariable("other");
But its reutrning null value
I have username. So what i did is passing my username as parameter to NTAccount constructor and getting sid of user. below is the code.
NTAccount f = new NTAccount(username);
SecurityIdentifier s = (SecurityIdentifier)f.Translate(typeof(SecurityIdentifier));
string sid = s.ToString();
after that using that sid i am getting profile folder by reading the value from registry using below path.
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\sid
under that path there is key call profileimagepath there i can get the user profile pat
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.