You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: xml/System/Environment.xml
+28-40Lines changed: 28 additions & 40 deletions
Original file line number
Diff line number
Diff line change
@@ -761,8 +761,8 @@ On macOS and Linux, the environment block of the current proccess includes the f
761
761
762
762
The following example attempts to retrieve the value of an environment variable named `Test1` from the process environment block. If the variable doesn't exist, the example creates its and retrieves its value. The example displays the value of the variable. If the example created the variable, it also calls the <xref:System.Environment.GetEnvironmentVariables%28System.EnvironmentVariableTarget%29> method with each member of the <xref:System.EnvironmentVariableTarget> enumeration to establish that the variable can be retrieved only from the current process environment block. Finally, if the example created the variable, it deletes it.
@@ -813,7 +813,7 @@ On macOS and Linux, the environment block of the current proccess includes the f
813
813
</Parameters>
814
814
<Docs>
815
815
<paramname="variable">The name of an environment variable.</param>
816
-
<paramname="target">One of the <seecref="T:System.EnvironmentVariableTarget" /> values.</param>
816
+
<paramname="target">One of the <seecref="T:System.EnvironmentVariableTarget" /> values. Only <seecref="F:System.EnvironmentVariableTarget.Process" /> is supported on .NET Core running on Unix-bases systems.</param>
817
817
<summary>Retrieves the value of an environment variable from the current process or from the Windows operating system registry key for the current user or local machine.</summary>
818
818
<returns>The value of the environment variable specified by the <paramrefname="variable" /> and <paramrefname="target" /> parameters, or <seelangword="null" /> if the environment variable is not found.</returns>
- Those defined by calling either the <xref:System.Environment.SetEnvironmentVariable%28System.String%2CSystem.String%29> method or the <xref:System.Environment.SetEnvironmentVariable%28System.String%2CSystem.String%2CSystem.EnvironmentVariableTarget%29> method with a `target` value of <xref:System.EnvironmentVariableTarget.Process?displayProperty=nameWithType>. These environment variables persist only until the `dotnet` process or the .NET application terminates.
841
841
842
-
## Examples
843
-
The following example creates environment variables for the Process, User, and Machine targets, checks whether the operating system registry contains the User and Machine environment variables, then deletes the environment variables.
The following example creates environment variables for the <xref:System.EnvironmentVariableTarget.Process?displayProperty=nameWithType>, <xref:System.EnvironmentVariableTarget.User?displayProperty=nameWithType>, and <xref:System.EnvironmentVariableTarget.Machine> targets, checks whether the operating system registry contains the user and machine environment variables, then deletes the environment variables. Because .NET on Unix-based systems does not support per-user and per-machine environment variables, only <xref:System.Environment.SetEnvironmentVariable(System.String,System.String)> and <xref:System.Environment.SetEnvironmentVariable(System.String,System.String,System.EnvironmentVariableTarget)> with a value of <xref:System.EnvironmentVariableTarget.Process?displayProperty=nameWithType> successfully store an environment variable to the process environment block.
On Windows systems, the `GetEnvironmentVariables` method returns the following environment variabless:
924
+
On Windows systems, the `GetEnvironmentVariables` method returns the following environment variables:
925
925
926
926
- All per-machine environment variables that are defined at the time the process is created, along with their values.
927
927
@@ -933,7 +933,7 @@ On Windows systems, the `GetEnvironmentVariables` method returns the following e
933
933
934
934
On MacOS and Linux, the `GetEnvironmentVariables` method retrieves the name and value of all environment variables that are inherited from the parent process that launched the `dotnet` process or that are defined within the scope of the `dotnet` process itself. Once the `dotnet` process ends, these latter environment variables cease to exist.
935
935
936
-
.NET Core does not support per-machine or per-user environment variables.
936
+
.NET Core running on Unix-based systems does not support per-machine or per-user environment variables.
937
937
938
938
## Examples
939
939
The following example demonstrates the <xref:System.Environment.GetEnvironmentVariables%2A> method.
@@ -986,7 +986,7 @@ On MacOS and Linux, the `GetEnvironmentVariables` method retrieves the name and
<paramname="target">One of the <seecref="T:System.EnvironmentVariableTarget" /> values.</param>
989
+
<paramname="target">One of the <seecref="T:System.EnvironmentVariableTarget" /> values. Only <seecxref="F:System.EnvironmentVariableTarget.Process" /> is supported on .NET Core running on Unix-based systems. </param>
990
990
<summary>Retrieves all environment variable names and their values from the current process, or from the Windows operating system registry key for the current user or local machine.</summary>
991
991
<returns>A dictionary that contains all environment variable names and their values from the source specified by the <paramrefname="target" /> parameter; otherwise, an empty dictionary if no environment variables are found.</returns>
992
992
<remarks>
@@ -1006,12 +1006,12 @@ On macOS and Linux, only a `target` value of <xref:System.EnvironmentVariableTar
1006
1006
1007
1007
Per-machine and per-user environment variables are not supported. A `target` value of <xref:System.EnvironmentVariableTarget.Machine?displayProperty=nameWithType> or <xref:System.EnvironmentVariableTarget.User?displayProperty=nameWithType> returns an empty array.
1008
1008
1009
-
## Examples
1010
-
The following example creates environment variables for the Process, User, and Machine targets, checks whether the operating system registry contains the User and Machine environment variables, then deletes the environment variables.
The following example creates environment variables for the <xref:System.EnvironmentVariableTarget.Process?displayProperty=nameWithType>, <xref:System.EnvironmentVariableTarget.User?displayProperty=nameWithType>, and <xref:System.EnvironmentVariableTarget.Machine> targets, checks whether the operating system registry contains the user and machine environment variables, then deletes the environment variables. Because .NET on Unix-based systems does not support per-user and per-machine environment variables, only <xref:System.Environment.SetEnvironmentVariable(System.String,System.String)> and <xref:System.Environment.SetEnvironmentVariable(System.String,System.String,System.EnvironmentVariableTarget)> with a value of <xref:System.EnvironmentVariableTarget.Process?displayProperty=nameWithType> successfully store an environment variable to the process environment block.
@@ -1652,24 +1652,12 @@ The `Environment.OSVersion` property does not provide a reliable way to identify
1652
1652
1653
1653
- It consists of a single character whose value is U+0000.
1654
1654
1655
-
1656
-
1657
-
## Examples
1658
-
The following example tests whether an environment variable named `APPDOMAIN` exists in the current process. If it does not, it creates it and sets its value to "True". If the value of the `APPDOMAIN` environment variable is "True", it calls the `Message.Display` method in a new application domain. Otherwise, it executes the `Message.Display` method in the current application domain.
If you run the example for the first time, the message "Executing in domain Domain2" displays to the console. If you set the environment variable from the command line by using the command:
1664
-
1665
-
`Set AppDomain=False`
1666
-
1667
-
the example displays the message "Executing in domain *exeName*.exe", where *exeName* is the name of the executable.
1668
-
1669
-
The following example attempts to retrieve the value of an environment variable named `Test1` from the process environment block. If the variable doesn't exist, the example creates the variable and retrieves its value. The example displays the value of the variable. If the example created the variable, it also calls the <xref:System.Environment.GetEnvironmentVariables%28System.EnvironmentVariableTarget%29> method with each member of the <xref:System.EnvironmentVariableTarget> enumeration to establish that the variable can be retrieved only from the current process environment block. Finally, if the example created the variable, it deletes it.
1655
+
## Examples
1656
+
1657
+
The following example attempts to retrieve the value of an environment variable named `Test1` from the process environment block. If the variable doesn't exist, the example creates the variable and retrieves its value. The example displays the value of the variable. For .NET implementations running on Windows systems, it also calls the <xref:System.Environment.GetEnvironmentVariables%28System.EnvironmentVariableTarget%29> method with each member of the <xref:System.EnvironmentVariableTarget> enumeration to establish that the variable can be retrieved only from the current process environment block. (.NET implementations on Unix-based systems only support variables in the process environment block.) Finally, if the example created the variable, it deletes it.
@@ -1770,12 +1758,12 @@ If `target` is <xref:System.EnvironmentVariableTarget.User?displayProperty=nameW
1770
1758
1771
1759
If `target` is <xref:System.EnvironmentVariableTarget.User?displayProperty=nameWithType> or <xref:System.EnvironmentVariableTarget.Machine?displayProperty=nameWithType>, we recommend that the length of `value` be less than 2048 characters.
1772
1760
1773
-
## Examples
1774
-
The following example creates environment variables for the <xref:System.EnvironmentVariableTarget.Process?displayProperty=nameWithType>, <xref:System.EnvironmentVariableTarget.User?displayProperty=nameWithType>, and <xref:System.EnvironmentVariableTarget.Machine> targets, checks whether the operating system registry contains the user and machine environment variables, then deletes the environment variables.
1761
+
## Examples
1762
+
1763
+
The following example creates environment variables for the <xref:System.EnvironmentVariableTarget.Process?displayProperty=nameWithType>, <xref:System.EnvironmentVariableTarget.User?displayProperty=nameWithType>, and <xref:System.EnvironmentVariableTarget.Machine> targets, checks whether the operating system registry contains the user and machine environment variables, then deletes the environment variables. Because .NET on Unix-based systems does not support per-user and per-machine environment variables, only <xref:System.Environment.SetEnvironmentVariable(System.String,System.String)> and <xref:System.Environment.SetEnvironmentVariable(System.String,System.String,System.EnvironmentVariableTarget)> with a value of <xref:System.EnvironmentVariableTarget.Process?displayProperty=nameWithType> successfully store an environment variable to the process environment block.
0 commit comments