A
A
Andrey Ostanin2016-02-24 15:14:03
.NET
Andrey Ostanin, 2016-02-24 15:14:03

How to determine the username?

I'm trying to determine the username that my UWP app is using. Tried through Environment.UserName, VS writes that "Environment" does not contain a definition for "UserName". What else to try?
VS2015, .NET 4.5.2

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Melz, 2016-02-24
@Kaberc

you here .

IReadOnlyList<User> users = await User.FindAllAsync(UserType.LocalUser, UserAuthenticationStatus.LocallyAuthenticated);
User user = users.FirstOrDefault();

Don't forget to enable it in Package.appxmanifest -> Capabilities tab -> User Account Information.
You also need a class which is in Windows.System.User.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question