Windows 7: How can I get a list of all Windows user names in .Net?
Is there a simple way to get the names of all the user names of a local Windows 7 machine using .Net? So if I had a machine named MyPC, and it had 3 users MyPC\Mike, MyPC\Bob, and MyPC\Steve, I'd just want to be able to query to get Mike, Bob, and Steve. Of course, I don't care if they have the compu开发者_如何学运维ter name attached, or not, as well.
If no-one comes up with a better way, you could enumerate the \Users folder and use the folders in there as representations. (Providing each user has logged in and the network isn't using roaming profiles)
http://www.codeproject.com/KB/cs/enumerate_system_users.aspx
精彩评论