如何在使用C#的.NET中获取当前用户名?
如果您处于用户网络中,则用户名将不同:
Environment.UserName - Will Display format : 'Username'
而不是
System.Security.Principal.WindowsIdentity.GetCurrent().Name - Will Display format : 'NetworkName\Username'
请选择您想要的格式。
string userName = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
(这是一个HTML标签,含义为加粗显示123)
用户名或电子邮箱地址
密码