mscorlib(4.0.0.0) API with additions
|
Provides information about, and means to manipulate, the current environment and platform. This class cannot be inherited. More...
Public Member Functions | |
static void | FailFast (string message) |
Immediately terminates a process after writing a message to the Windows Application event log, and then includes the message in error reporting to Microsoft. More... | |
static void | FailFast (string message, Exception exception) |
Immediately terminates a process after writing a message to the Windows Application event log, and then includes the message and exception information in error reporting to Microsoft. More... | |
Static Public Member Functions | |
static void | Exit (int exitCode) |
Terminates this process and returns an exit code to the operating system. More... | |
static string | ExpandEnvironmentVariables (string name) |
Replaces the name of each environment variable embedded in the specified string with the string equivalent of the value of the variable, then returns the resulting string. More... | |
static string [] | GetCommandLineArgs () |
Returns a string array containing the command-line arguments for the current process. More... | |
static string | GetEnvironmentVariable (string variable) |
Retrieves the value of an environment variable from the current process. More... | |
static string | GetEnvironmentVariable (string variable, EnvironmentVariableTarget target) |
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. More... | |
static IDictionary | GetEnvironmentVariables () |
Retrieves all environment variable names and their values from the current process. More... | |
static IDictionary | GetEnvironmentVariables (EnvironmentVariableTarget target) |
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. More... | |
static void | SetEnvironmentVariable (string variable, string value) |
Creates, modifies, or deletes an environment variable stored in the current process. More... | |
static void | SetEnvironmentVariable (string variable, string value, EnvironmentVariableTarget target) |
Creates, modifies, or deletes an environment variable stored in the current process or in the Windows operating system registry key reserved for the current user or local machine. More... | |
static string [] | GetLogicalDrives () |
Returns an array of string containing the names of the logical drives on the current computer. More... | |
static string | GetFolderPath (SpecialFolder folder) |
Gets the path to the system special folder that is identified by the specified enumeration. More... | |
static string | GetFolderPath (SpecialFolder folder, SpecialFolderOption option) |
Gets the path to the system special folder that is identified by the specified enumeration, and uses a specified option for accessing special folders. More... | |
Static Public Attributes | |
static Version | Version => new Version(4, 0, 30319, 42000) |
Gets a T:System.Version object that describes the major, minor, build, and revision numbers of the common language runtime. More... | |
static bool | Is64BitProcess => true |
Determines whether the current process is a 64-bit process. More... | |
Properties | |
static int | TickCount [get] |
Gets the number of milliseconds elapsed since the system started. More... | |
static int | ExitCode [get, set] |
Gets or sets the exit code of the process. More... | |
static string | CommandLine [get] |
Gets the command line for this process. More... | |
static string | CurrentDirectory [get, set] |
Gets or sets the fully qualified path of the current working directory. More... | |
static string | SystemDirectory [get] |
Gets the fully qualified path of the system directory. More... | |
static string | MachineName [get] |
Gets the NetBIOS name of this local computer. More... | |
static int | ProcessorCount [get] |
Gets the number of processors on the current machine. More... | |
static int | SystemPageSize [get] |
Gets the number of bytes in the operating system's memory page. More... | |
static string | NewLine [get] |
Gets the newline string defined for this environment. More... | |
static long | WorkingSet [get] |
Gets the amount of physical memory mapped to the process context. More... | |
static OperatingSystem | OSVersion [get] |
Gets an T:System.OperatingSystem object that contains the current platform identifier and version number. More... | |
static string | StackTrace [get] |
Gets current stack trace information. More... | |
static bool | Is64BitOperatingSystem [get] |
Determines whether the current operating system is a 64-bit operating system. More... | |
static bool | HasShutdownStarted [get] |
Gets a value that indicates whether the current application domain is being unloaded or the common language runtime (CLR) is shutting down. More... | |
static string | UserName [get] |
Gets the user name of the person who is currently logged on to the Windows operating system. More... | |
static bool | UserInteractive [get] |
Gets a value indicating whether the current process is running in user interactive mode. More... | |
static string | UserDomainName [get] |
Gets the network domain name associated with the current user. More... | |
static int | CurrentManagedThreadId [get] |
Gets a unique identifier for the current managed thread. More... | |
Provides information about, and means to manipulate, the current environment and platform. This class cannot be inherited.
Definition at line 21 of file Environment.cs.
|
strong |
Specifies enumerated constants used to retrieve directory paths to system special folders.
Enumerator | |
---|---|
ApplicationData | The directory that serves as a common repository for application-specific data for the current roaming user. |
CommonApplicationData | The directory that serves as a common repository for application-specific data that is used by all users. |
LocalApplicationData | The directory that serves as a common repository for application-specific data that is used by the current, non-roaming user. |
Cookies | The directory that serves as a common repository for Internet cookies. |
Desktop | The logical Desktop rather than the physical file system location. |
Favorites | The directory that serves as a common repository for the user's favorite items. |
History | The directory that serves as a common repository for Internet history items. |
InternetCache | The directory that serves as a common repository for temporary Internet files. |
Programs | The directory that contains the user's program groups. |
MyComputer | The My Computer folder. |
MyMusic | The My Music folder. |
MyPictures | The My Pictures folder. |
MyVideos | The file system directory that serves as a repository for videos that belong to a user. Added in the .NET Framework 4. |
Recent | The directory that contains the user's most recently used documents. |
SendTo | The directory that contains the Send To menu items. |
StartMenu | The directory that contains the Start menu items. |
Startup | The directory that corresponds to the user's Startup program group. |
System | The System directory. |
Templates | The directory that serves as a common repository for document templates. |
DesktopDirectory | The directory used to physically store file objects on the desktop. |
Personal | The directory that serves as a common repository for documents. |
MyDocuments | The My Documents folder. |
ProgramFiles | The program files directory.On a non-x86 system, passing F:System.Environment.SpecialFolder.ProgramFiles to the M:System.Environment.GetFolderPath(System.Environment.SpecialFolder) method returns the path for non-x86 programs. To get the x86 program files directory on a non-x86 system, use the F:System.Environment.SpecialFolder.ProgramFilesX86 member. |
CommonProgramFiles | The directory for components that are shared across applications.To get the x86 common program files directory on a non-x86 system, use the F:System.Environment.SpecialFolder.ProgramFilesX86 member. |
AdminTools | The file system directory that is used to store administrative tools for an individual user. The Microsoft Management Console (MMC) will save customized consoles to this directory, and it will roam with the user. Added in the .NET Framework 4. |
CDBurning | The file system directory that acts as a staging area for files waiting to be written to a CD. Added in the .NET Framework 4. |
CommonAdminTools | The file system directory that contains administrative tools for all users of the computer. Added in the .NET Framework 4. |
CommonDocuments | The file system directory that contains documents that are common to all users. This special folder is valid for Windows NT systems, Windows 95, and Windows 98 systems with Shfolder.dll installed. Added in the .NET Framework 4. |
CommonMusic | The file system directory that serves as a repository for music files common to all users. Added in the .NET Framework 4. |
CommonOemLinks | This value is recognized in Windows Vista for backward compatibility, but the special folder itself is no longer used. Added in the .NET Framework 4. |
CommonPictures | The file system directory that serves as a repository for image files common to all users. Added in the .NET Framework 4. |
CommonStartMenu | The file system directory that contains the programs and folders that appear on the Start menu for all users. This special folder is valid only for Windows NT systems. Added in the .NET Framework 4. |
CommonPrograms | A folder for components that are shared across applications. This special folder is valid only for Windows NT, Windows 2000, and Windows XP systems. Added in the .NET Framework 4. |
CommonStartup | The file system directory that contains the programs that appear in the Startup folder for all users. This special folder is valid only for Windows NT systems. Added in the .NET Framework 4. |
CommonDesktopDirectory | The file system directory that contains files and folders that appear on the desktop for all users. This special folder is valid only for Windows NT systems. Added in the .NET Framework 4. |
CommonTemplates | The file system directory that contains the templates that are available to all users. This special folder is valid only for Windows NT systems. Added in the .NET Framework 4. |
CommonVideos | The file system directory that serves as a repository for video files common to all users. Added in the .NET Framework 4. |
Fonts | A virtual folder that contains fonts. Added in the .NET Framework 4. |
NetworkShortcuts | A file system directory that contains the link objects that may exist in the My Network Places virtual folder. Added in the .NET Framework 4. |
PrinterShortcuts | The file system directory that contains the link objects that can exist in the Printers virtual folder. Added in the .NET Framework 4. |
UserProfile | The user's profile folder. Applications should not create files or folders at this level; they should put their data under the locations referred to by F:System.Environment.SpecialFolder.ApplicationData. Added in the .NET Framework 4. |
CommonProgramFilesX86 | The Program Files folder. Added in the .NET Framework 4. |
ProgramFilesX86 | The x86 Program Files folder. Added in the .NET Framework 4. |
Resources | The file system directory that contains resource data. Added in the .NET Framework 4. |
LocalizedResources | The file system directory that contains localized resource data. Added in the .NET Framework 4. |
SystemX86 | The Windows System folder. Added in the .NET Framework 4. |
Windows | The Windows directory or SYSROOT. This corresponds to the windir% or SYSTEMROOT% environment variables. Added in the .NET Framework 4. |
Definition at line 164 of file Environment.cs.
|
strong |
Specifies options to use for getting the path to a special folder.
Definition at line 152 of file Environment.cs.
|
static |
Terminates this process and returns an exit code to the operating system.
exitCode | The exit code to return to the operating system. Use 0 (zero) to indicate that the process completed successfully. |
T:System.Security.SecurityException | The caller does not have sufficient security permission to perform this function. |
Definition at line 670 of file Environment.cs.
|
static |
Replaces the name of each environment variable embedded in the specified string with the string equivalent of the value of the variable, then returns the resulting string.
name | A string containing the names of zero or more environment variables. Each environment variable is quoted with the percent sign character (%). |
T:System.ArgumentNullException | name is null . |
Definition at line 718 of file Environment.cs.
static void System.Environment.FailFast | ( | string | message | ) |
Immediately terminates a process after writing a message to the Windows Application event log, and then includes the message in error reporting to Microsoft.
message | A message that explains why the process was terminated, or null if no explanation is provided. |
static void System.Environment.FailFast | ( | string | message, |
Exception | exception | ||
) |
Immediately terminates a process after writing a message to the Windows Application event log, and then includes the message and exception information in error reporting to Microsoft.
message | A message that explains why the process was terminated, or null if no explanation is provided. |
exception | An exception that represents the error that caused the termination. This is typically the exception in a catch block. |
|
static |
Returns a string array containing the command-line arguments for the current process.
T:System.NotSupportedException | The system does not support command-line arguments. |
Definition at line 806 of file Environment.cs.
|
static |
Retrieves the value of an environment variable from the current process.
variable | The name of the environment variable. |
null
if the environment variable is not found.T:System.ArgumentNullException | variable is null . |
T:System.Security.SecurityException | The caller does not have the required permission to perform this operation. |
Definition at line 828 of file Environment.cs.
|
static |
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.
variable | The name of an environment variable. |
target | One of the T:System.EnvironmentVariableTarget values. |
null
if the environment variable is not found.T:System.ArgumentNullException | variable is null . |
T:System.ArgumentException | target is not a valid T:System.EnvironmentVariableTarget value. |
T:System.Security.SecurityException | The caller does not have the required permission to perform this operation. |
Definition at line 865 of file Environment.cs.
|
static |
Retrieves all environment variable names and their values from the current process.
T:System.Security.SecurityException | The caller does not have the required permission to perform this operation. |
T:System.OutOfMemoryException | The buffer is out of memory. |
Definition at line 954 of file Environment.cs.
|
static |
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.
target | One of the T:System.EnvironmentVariableTarget values. |
T:System.Security.SecurityException | The caller does not have the required permission to perform this operation for the specified value of target . |
T:System.ArgumentException | target contains an illegal value. |
Definition at line 1032 of file Environment.cs.
|
static |
Gets the path to the system special folder that is identified by the specified enumeration.
folder | An enumerated constant that identifies a system special folder. |
T:System.ArgumentException | folder is not a member of T:System.Environment.SpecialFolder. |
T:System.PlatformNotSupportedException | The current platform is not supported. |
Definition at line 1336 of file Environment.cs.
|
static |
Gets the path to the system special folder that is identified by the specified enumeration, and uses a specified option for accessing special folders.
folder | An enumerated constant that identifies a system special folder. |
option | Specifies options to use for accessing a special folder. |
T:System.ArgumentException | folder is not a member of T:System.Environment.SpecialFolder |
T:System.PlatformNotSupportedException | T:System.PlatformNotSupportedException |
Definition at line 1355 of file Environment.cs.
|
static |
Returns an array of string containing the names of the logical drives on the current computer.
T:System.IO.IOException | An I/O error occurs. |
T:System.Security.SecurityException | The caller does not have the required permissions. |
Definition at line 1201 of file Environment.cs.
|
static |
Creates, modifies, or deletes an environment variable stored in the current process.
variable | The name of an environment variable. |
value | A value to assign to variable . |
T:System.ArgumentNullException | variable is null . |
T:System.ArgumentException | variable contains a zero-length string, an initial hexadecimal zero character (0x00), or an equal sign ("="). -or-The length of variable or value is greater than or equal to 32,767 characters.-or-An error occurred during the execution of this operation. |
T:System.Security.SecurityException | The caller does not have the required permission to perform this operation. |
Definition at line 1066 of file Environment.cs.
|
static |
Creates, modifies, or deletes an environment variable stored in the current process or in the Windows operating system registry key reserved for the current user or local machine.
variable | The name of an environment variable. |
value | A value to assign to variable . |
target | One of the enumeration values that specifies the location of the environment variable. |
T:System.ArgumentNullException | variable is null . |
T:System.ArgumentException | variable contains a zero-length string, an initial hexadecimal zero character (0x00), or an equal sign ("="). -or-The length of variable is greater than or equal to 32,767 characters.-or- target is not a member of the T:System.EnvironmentVariableTarget enumeration. -or- target is F:System.EnvironmentVariableTarget.Machine or F:System.EnvironmentVariableTarget.User, and the length of variable is greater than or equal to 255.-or- target is F:System.EnvironmentVariableTarget.Process and the length of value is greater than or equal to 32,767 characters. -or-An error occurred during the execution of this operation. |
T:System.Security.SecurityException | The caller does not have the required permission to perform this operation. |
Definition at line 1134 of file Environment.cs.
|
static |
Determines whether the current process is a 64-bit process.
true
if the process is 64-bit; otherwise, false
.Definition at line 546 of file Environment.cs.
Gets a T:System.Version object that describes the major, minor, build, and revision numbers of the common language runtime.
Definition at line 459 of file Environment.cs.
|
staticget |
Gets the command line for this process.
Definition at line 337 of file Environment.cs.
|
staticgetset |
Gets or sets the fully qualified path of the current working directory.
T:System.ArgumentException | Attempted to set to an empty string (""). |
T:System.ArgumentNullException | Attempted to set to null. |
T:System.IO.IOException | An I/O error occurred. |
T:System.IO.DirectoryNotFoundException | Attempted to set a local path that cannot be found. |
T:System.Security.SecurityException | The caller does not have the appropriate permission. |
Definition at line 356 of file Environment.cs.
|
staticget |
Gets a unique identifier for the current managed thread.
Definition at line 651 of file Environment.cs.
|
staticgetset |
Gets or sets the exit code of the process.
Definition at line 316 of file Environment.cs.
|
staticget |
Gets a value that indicates whether the current application domain is being unloaded or the common language runtime (CLR) is shutting down.
true
if the current application domain is being unloaded or the CLR is shutting down; otherwise, false.
Definition at line 565 of file Environment.cs.
|
staticget |
Determines whether the current operating system is a 64-bit operating system.
true
if the operating system is 64-bit; otherwise, false
.Definition at line 552 of file Environment.cs.
|
staticget |
Gets the NetBIOS name of this local computer.
T:System.InvalidOperationException | The name of this computer cannot be obtained. |
Definition at line 403 of file Environment.cs.
|
staticget |
Gets the newline string defined for this environment.
Definition at line 449 of file Environment.cs.
|
staticget |
Gets an T:System.OperatingSystem object that contains the current platform identifier and version number.
T:System.InvalidOperationException | This property was unable to obtain the system version.-or- The obtained platform identifier is not a member of T:System.PlatformID |
Definition at line 477 of file Environment.cs.
|
staticget |
Gets the number of processors on the current machine.
Definition at line 422 of file Environment.cs.
|
staticget |
Gets current stack trace information.
Definition at line 533 of file Environment.cs.
|
staticget |
Gets the fully qualified path of the system directory.
Definition at line 370 of file Environment.cs.
|
staticget |
Gets the number of bytes in the operating system's memory page.
Definition at line 434 of file Environment.cs.
|
staticget |
Gets the number of milliseconds elapsed since the system started.
Definition at line 306 of file Environment.cs.
|
staticget |
Gets the network domain name associated with the current user.
T:System.PlatformNotSupportedException | The operating system does not support retrieving the network domain name. |
T:System.InvalidOperationException | The network domain name cannot be retrieved. |
Definition at line 618 of file Environment.cs.
|
staticget |
Gets a value indicating whether the current process is running in user interactive mode.
true
if the current process is running in user interactive mode; otherwise, false
.Definition at line 594 of file Environment.cs.
|
staticget |
Gets the user name of the person who is currently logged on to the Windows operating system.
Definition at line 575 of file Environment.cs.
|
staticget |
Gets the amount of physical memory mapped to the process context.
Definition at line 464 of file Environment.cs.