Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

c# get username

string userName = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
Comment

c# get username

Environment.UserName
Comment

c# get username


string userName = System.Security.Principal.WindowsIdentity.GetCurrent().Name;

Comment

c# get logged on user name

foreach (System.Management.ManagementObject Process in Processes.Get())
{
    if (Process["ExecutablePath"] != null && 
        System.IO.Path.GetFileName(Process["ExecutablePath"].ToString()).ToLower() == "explorer.exe" )
    {
        string[] OwnerInfo = new string[2];
        Process.InvokeMethod("GetOwner", (object[])OwnerInfo);

        Console.WriteLine(string.Format("Windows Logged-in Interactive UserName={0}", OwnerInfo[0]));

        break;
    }
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: autofac .net core 6 
Csharp :: convert uint to int C# 
Csharp :: yield in c# 
Csharp :: unity reset random seed 
Csharp :: random string generator c# 
Csharp :: Search for a value into a list in c# 
Csharp :: how to add to a list in c# 
Csharp :: unity switch to scene and transfer data 
Csharp :: convert pdf to image c# 
Csharp :: how to use curl in asp.net c# 
Csharp :: switch statement c# example 
Csharp :: unity get prefabs from folder 
Csharp :: c# modulo 
Csharp :: unity list get item at index 
Csharp :: same click event diffrenet buttonms c# 
Csharp :: expansion tile 
Csharp :: get min date in list c# 
Csharp :: expando object c# 
Csharp :: how to see if a number is even c# 
Csharp :: player input manager join manually 
Csharp :: c# check if object is of any generic type 
Csharp :: c# get smallest of 3 numbers 
Csharp :: how to add event function from code in wpf 
Csharp :: c# convertir caracter con tilde 
Csharp :: update browserslist 
Csharp :: Options Pattern startup.cs configuration 
Csharp :: spin with rigidbody 2d unity 
Csharp :: c# object is enum 
Csharp :: unity magnetize a 3d object to cursor 
Csharp :: c# on variable change property get set 
ADD CONTENT
Topic
Content
Source link
Name
4+1 =