public sealed class Environment
|
CommandLine | Read-only Gets the command line for this process. |
CurrentDirectory | Read-write Gets and sets the fully qualified path of the current directory; that is, the directory from which this process starts. |
ExitCode | Read-write Gets or sets the exit code of the process. |
HasShutdownStarted | Read-only Indicates whether the common language runtime is shutting down. |
NewLine | Read-only Gets the newline string defined for this environment. |
StackTrace | Read-only Gets current stack trace information. |
SystemDirectory | Read-only Gets the fully qualified path of the system directory. |
TickCount | Read-only Gets the number of milliseconds elapsed since the system started. |
Version | Read-only Gets a Version object that describes the major, minor, build, and revision numbers of the common language runtime. |
WorkingSet | Read-only Gets the amount of physical memory mapped to the process context. |
Equals (inherited from System.Object) |
See base class member description: System.Object.Equals Derived from System.Object, the primary base class for all objects. |
Exit | Terminates this process and gives the underlying operating system the specified exit code. |
GetCommandLineArgs | Returns a string array containing the command line arguments for the current process. |
GetEnvironmentVariable | Returns the value of the specified environment variable. |
GetEnvironmentVariables | Returns all environment variables and their values. |
GetHashCode (inherited from System.Object) |
See base class member description: System.Object.GetHashCode Derived from System.Object, the primary base class for all objects. |
GetLogicalDrives | Returns an array of string containing the names of the logical drives on the current computer. |
GetType (inherited from System.Object) |
See base class member description: System.Object.GetType Derived from System.Object, the primary base class for all objects. |
ToString (inherited from System.Object) |
See base class member description: System.Object.ToString Derived from System.Object, the primary base class for all objects. |
Finalize (inherited from System.Object) |
See base class member description: System.Object.Finalize Derived from System.Object, the primary base class for all objects. |
MemberwiseClone (inherited from System.Object) |
See base class member description: System.Object.MemberwiseClone Derived from System.Object, the primary base class for all objects. |
Hierarchy:
public static string CommandLine {get;}
|
The program name can, but is not required to, include path information. Use the Environment.GetCommandLineArgs method to retrieve the command line information parsed and stored in an array of strings.
public static string CurrentDirectory {get; set;}
|
Exception Type | Condition |
---|---|
ArgumentException | Attempted to set to an empty string (""). |
ArgumentNullException | Attempted to set to null. |
IOException | An I/O error occurred. |
DirectoryNotFoundException | Attempted to set a path that cannot be found. |
SecurityException | The caller does not have the appropriate permission. |
public static int ExitCode {get; set;}
|
The system exit code is set to the return value of the function, main, or zero if main returns void, regardless of whether the user sets this property.
public bool HasShutdownStarted {get;}
|
An object's finalization method is called in one of the following situations: during garbage collection, when the application domain that contains the object is unloaded, or when the common language runtime is shutting down.
While executing in your finalization method when the common language runtime is shutting down, you might want to access another object that is referenced by a static field and has a finalization method. However, you cannot reliably do so because the accessed object might already have been finalized.
Use this method in an object's finalization method to determine whether the common language runtime is shutting down. If that is the case, you cannot reliably access any object that has a finalization method and is referenced by a static field.
public static string NewLine {get;}
|
This value is automatically appended to text when using WriteLine methods, such as Console.WriteLine.
public static string StackTrace {get;}
|
Exception Type | Condition |
---|---|
ArgumentOutOfRangeException | The requested stack trace information is out of range. |
at FullClassName.MethodName(MethodParams) in FileName: line
LineNumber
FullClassName, MethodName, MethodParms, FileName, and LineNumber are defined as follows: The literal "at" is preceded by a single space.
The literals "in" and ":line" are omitted if debug symbols are not available.
The method calls are described in reverse chronological order (the most recent method call is described first).
StackTrace might not report as many method calls as expected, due to code transformations that occur during optimization.
public static string SystemDirectory {get;}
|
public static int TickCount {get;}
|
The resolution of the TickCount property cannot be less than 500 milliseconds.
The TickCount property handles an overflow condition by resetting its value to zero. The minimum value returned by TickCount is 0.
TickCount is different from the DateTime.Ticks property, which is the number of 100-nanosecond intervals that have elapsed since 1/1/0001, 12:00am.
Use the DateTime.Now property to obtain the current local date and time on this computer.
public static Version Version {get;}
|
public static long WorkingSet {get;}
|
public static void Exit( |
exitCode
Exception Type | Condition |
---|---|
SecurityException | The caller does not have sufficient security permissions to perform this function. The caller must have an unrestricted PermissionSet. |
~Environment(); |
public static string[] GetCommandLineArgs(); |
Exception Type | Condition |
---|---|
NotSupportedException | The system does not support command line arguments. |
The program file name can, but is not required to, include path information.
To obtain the command line as a single string, use the Environment.CommandLine property.
variable
Exception Type | Condition |
---|---|
ArgumentNullException | variable is null. |
SecurityException | The caller does not have EnvironmentPermission with EnvironmentPermissionAccess.Read access. |
public static IDictionary GetEnvironmentVariables(); |
public virtual int GetHashCode(); |
public static string[] GetLogicalDrives(); |
Exception Type | Condition |
---|---|
IOException | An I/O error occurs. |
SecurityException | The caller does not have the required permissions. |
public Type GetType(); |
protected object MemberwiseClone(); |
public virtual string ToString(); |