简体   繁体   中英

C# Why can't I access domain user's local folder under C:\Users?

I have a laptop connected to a domain named Homebase, where I have a domain user (Jamie L. Horton) logged in. On that laptop I also have a local account named Jamie which I don't use, but I'd rather not delete it. The problem is I am trying to access my domain user's local Download folder.

If I look under C:\\Users it shows a folder for Jamie and one for Jamie.HOMEBASE. If I try to access this folder in C# "C:\\Users\\Jamie.HOMEBASE" it throws a Directory Not Found Exception. If I look at all the folders under C:\\Users in C# I do NOT see Jamie.HOMEBASE, but only one folder named Jamie. Which I checked whats inside and it is indeed the local user Jamie and not the domain user.

What's going on? How come I can access this folder in windows explorer with that path, but not with C#?

As Kosala W. said "Not running VS as an admin and trying to access a domain user folder will not work." The fix for me was to run VS as an admin and the problem was fixed.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM