C # using System.Environment operating system environment variables Chinese API

Static class: System.Environment

Description: Environment class provides information about the current environment and platform as well as their method of operation. It can not be inherited. Environment class can use to retrieve information, such as command-line arguments, exit code, environment variable settings, call the contents of the stack, since the last system boot time, and the version of the common language runtime and so on.

Attributes:

Abstract: The process of obtaining the command line.
public  static  String the CommandLine { GET ;} 
Abstract: get and set the current directory (i.e., the process from startup directory) fully qualified path. 
public  static  String CurrentDirectory { GET ; the SET ;} 
Summary: Gets or sets the process exit code. 
public  static  int the ExitCode { GET ; SET ;} 
Abstract: Gets a value indicating whether the common language runtime is shutting down or the current application domain is unloading. 
public  static  BOOL HasShutdownStarted { GET ;} 
Abstract: Get NetBIOS name of the local computer. 
public  static  String the MachineName { GET ;}
Abstract: Get wrap the string defined for this environment. "\ R \ n" for non-Unix platforms or "\ n" for Unix platforms. 
public  static  String the NewLine { GET ;} 
Abstract: Get System.OperatingSystem object contains the current platform identifier and version number. 
public  static of the OperatingSystem OSVersion { GET ;} 
Abstract: obtaining the current number of processors on a computer. 
public  static  int ProcessorCount { GET ;} 
Abstract: get the current stack trace information. 
public  static  String the StackTrace { GET ;} 
Abstract: acquiring fully qualified path of the system directory. 
public  static  String SystemDirectory { GET ;} 
Summary: Get the number of milliseconds elapsed after the system startup. 
public static  int the TickCount { GET ;} 
Abstract: Get the current network associated with the user domain. 
public  static  String UserDomainName { GET ;} 
Abstract: Gets a value indicating whether the current process running in user interactive mode. 
public  static  BOOL UserInteractive { GET ;} 
Summary: Get the current thread starts username of the person. 
public  static  String UserName { GET ;} 
Summary: Get a System.Version object that describes the main version of the common language runtime, minor version, build, and revision number. 
public  static Version Version { GET ;} 
Abstract: Get amount of physical memory mapped into the process context. 
public  static  Long WorkingSet { GET; }

method:

j Summary: terminate the process and provide the specified exit code is the underlying operating system.
public  static  void the Exit ( int The exitCode); 
Abstract: embedding into each environment variable name specified string replaces the string equivalent value for the variable, and then returns the resulting string. 
public  static  String ExpandEnvironmentVariables ( String name); 
Abstract: terminate the process but does not perform any activity the try - a finally block or terminator.
public  static  void the FailFast ( String the Message); 
Abstract: return to the command line string that contains the current process of the array parameter. 
public  static  String [] GetCommandLineArgs (); 
Abstract: retrieve values from the current process environment variables. 
public  static  String GetEnvironmentVariable ( Stringvariable); 
Abstract: The operating system environment variables to retrieve the value of the registry entries from the current Windows user or a local computer or from the current process. 
public  static  String GetEnvironmentVariable ( String variable, EnvironmentVariableTarget target); 
Abstract: Retrieve all environment variable names and their values from the current process. 
public  static IDictionary GetEnvironmentVariables (); 
Abstract: The current process or from the local computer or current user of the Windows operating system registry records are all environment variable names and their values. 
public  static IDictionary GetEnvironmentVariables (EnvironmentVariableTarget target); 
Abstract: Get the path to the enumeration identified by the specified system special folder. 
public  static  String the GetFolderPath (the Environment.SpecialFolder Folder); 
Abstract: Returns a string containing the current name of the logical drive array computer. 
public  static  String[] GetLogicalDrives (); 
Abstract: create, modify or delete environment variables stored in the current process. 
public  static  void the SetEnvironmentVariable ( String variable, String value); 
Abstract: create, modify or delete the current process, or for the current user or local Windows computer operating system registry reserved environment variables stored in the item. 
public  static  void the SetEnvironmentVariable ( String variable, String value, EnvironmentVariableTarget target);

 

Examples

String STR;
             String NL = Environment.NewLine; // Get linefeed character string defined for this environment.
            //
             Console.WriteLine (); 
            Console.WriteLine ( " - Members Environment - " ); 

            //   get the command line of a process. 
            Console.WriteLine ( " the CommandLine: {0} " , Environment.CommandLine);
             // Return command character string containing the current process line array parameter. 
            String [] = arguments Environment.GetCommandLineArgs (); 
            Console.WriteLine ( " the GetCommandLineArgs: {0} " , String.Join ( " ," , Arguments)); 

            // get and set the current directory (i.e., the process from startup directory) fully qualified path 
            Console.WriteLine ( " the CurrentDirectory: {0} " , Environment.CurrentDirectory);
             // get or set process exit code   
            Console.WriteLine ( " the ExitCode: {0} " , Environment.ExitCode);
         // . Gets a value indicating whether the common language runtime is shutting down or the current application domain is unloading 
            Console.WriteLine ( " HasShutdownStarted : {0} " , Environment.HasShutdownStarted); 

            //   <- the Keep the this Secure Information -!> 
            Console.WriteLine ( " the MachineName: {0} ", Environment.MachineName);

            Console.WriteLine("NewLine: {0}  first line{0}  second line{0}  third line",
                                  Environment.NewLine);

            Console.WriteLine("OSVersion: {0}", Environment.OSVersion.ToString());

            Console.WriteLine("StackTrace: '{0}'", Environment.StackTrace);

            //  <-- Keep this information secure! -->
            Console.WriteLine("SystemDirectory: {0}", Environment.SystemDirectory);

            Console.WriteLine("TickCount: {0}", Environment.TickCount);

            //  <-- Keep this information secure! -->
            Console.WriteLine("UserDomainName: {0}", Environment.UserDomainName);

            Console.WriteLine("UserInteractive: {0}", Environment.UserInteractive);

            //  <-- Keep this information secure! -->
            Console.WriteLine("UserName: {0}", Environment.UserName);

            Console.WriteLine("Version: {0}", Environment.Version.ToString());

            Console.WriteLine("WorkingSet: {0}", Environment.WorkingSet);

            //  No example for Exit(exitCode) because doing so would terminate this example.

            //  <-- Keep this information secure! -->
            string query = "My system drive is %SystemDrive% and my system root is %SystemRoot%";
            str = Environment.ExpandEnvironmentVariables(query);
            Console.WriteLine("ExpandEnvironmentVariables: {0}  {1}", nl, str);

            Console.WriteLine("GetEnvironmentVariable: {0}  My temporary directory is {1}.", nl,
                                   Environment.GetEnvironmentVariable("TEMP"));

            Console.WriteLine("GetEnvironmentVariables: ");
            IDictionary environmentVariables = Environment.GetEnvironmentVariables();
            foreach (DictionaryEntry de in environmentVariables)
            {
                Console.WriteLine("  {0} = {1}", de.Key, de.Value);
            }

            Console.WriteLine("GetFolderPath: {0}",
                         Environment.GetFolderPath(Environment.SpecialFolder.System));

            string[] drives = Environment.GetLogicalDrives();
            Console.WriteLine("GetLogicalDrives: {0}", String.Join(", ", drives));

 

Guess you like

Origin www.cnblogs.com/topsyuan/p/11204200.html