Thursday, July 15, 2010

Get System & Environment Variables in C#

This code is how to get system/environment variables in C#.

//current directory

public string path1 =
            Directory.GetCurrentDirectory();
//user domain name


public string path1 = 
            System.Environment.UserDomainName;

//machine name
public string path1 =
           System.Environment.MachineName;
//current user name
txtUsername.Text =
           System.Environment.UserName;

No comments:

Post a Comment