Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Environment Class

Provides information about, and means to manipulate, the current environment and platform. This class cannot be inherited.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)

[ComVisibleAttribute(true)]
public static class Environment

The Environment type exposes the following members.

  NameDescription
Public propertyStatic memberSupported by Silverlight for Windows PhoneSupported by Xbox 360CurrentDirectoryWhen called by trusted applications, gets the fully qualified path of the current working directory.
Public propertyStatic memberExitCodeGets or sets the exit code of the process.
Public propertyStatic memberSupported by Silverlight for Windows PhoneSupported by Xbox 360HasShutdownStartedGets a value indicating whether the common language runtime is shutting down or the current application domain is unloading.
Public propertyStatic memberSupported by Silverlight for Windows PhoneSupported by Xbox 360NewLineGets the newline string defined for this environment.
Public propertyStatic memberSupported by Silverlight for Windows PhoneSupported by Xbox 360OSVersionGets an OperatingSystem object that contains the current platform identifier and version number.
Public propertyStatic memberSupported by Silverlight for Windows PhoneSupported by Xbox 360ProcessorCountGets the number of processors on the current machine.
Public propertyStatic memberSupported by Silverlight for Windows PhoneSupported by Xbox 360TickCountGets the number of milliseconds elapsed since the system started.
Public propertyStatic memberSupported by Silverlight for Windows PhoneSupported by Xbox 360VersionGets a Version object that describes the major, minor, build, and revision numbers of the common language runtime.
Top

  NameDescription
Public methodStatic memberSupported by Silverlight for Windows PhoneSupported by Xbox 360GetFolderPathGets the path to the system special folder identified by the specified enumeration.
Top

Use the Environment class to retrieve information such as command-line arguments, the exit code, environment variable settings, contents of the call stack, time since last system boot, and the version of the common language runtime.

The following example demonstrates displays a list of information about the current environment.


// Sample for Environment class summary
using System;

class Example
{
   public static void Demo(System.Windows.Controls.TextBlock outputBlock)
   {
    outputBlock.Text += "-- Environment members --" + "\n";

    outputBlock.Text += String.Format("ExitCode: {0}", Environment.ExitCode) + "\n";

    outputBlock.Text += String.Format("HasShutdownStarted: {0}", Environment.HasShutdownStarted) + "\n";

    outputBlock.Text += String.Format("NewLine: {0}  first line{0}  second line{0}  third line",
                          Environment.NewLine) + "\n";

    outputBlock.Text += String.Format("OSVersion: {0}", Environment.OSVersion.ToString()) + "\n";

    outputBlock.Text += String.Format("TickCount: {0}", Environment.TickCount) + "\n";

    outputBlock.Text += String.Format("Version: {0}", Environment.Version.ToString()) + "\n";
   }
}


Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft