Condividi tramite


Environment.GetFolderPath Method

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Gets the path to the system special folder identified by the specified enumeration.

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

Syntax

'Declaration
<SecuritySafeCriticalAttribute> _
Public Shared Function GetFolderPath ( _
    folder As Environment..::..SpecialFolder _
) As String
[SecuritySafeCriticalAttribute]
public static string GetFolderPath(
    Environment..::..SpecialFolder folder
)

Parameters

Return Value

Type: System.String
The path to the specified system special folder, if that folder physically exists on your computer; otherwise, the empty string ("").
A folder will not physically exist if the operating system did not create it, the existing folder was deleted, or the folder is a virtual directory, such as My Computer, which does not correspond to a physical path.

Exceptions

Exception Condition
ArgumentException

folder is not a member of System.Environment.SpecialFolder.

PlatformNotSupportedException

The current platform is not supported.

Remarks

This method retrieves the path to a system special folder, such as Program Files, Programs, System, or Startup, which can be used to access common information. Special folders are set by default by the system, or explicitly by the user, when installing a version of Windows.

The folder parameter designates the special folder to retrieve and must be one of the values in the Environment.SpecialFolder enumeration; any other value throws an exception.

For more information about special folders, see the CSIDL values topic.

Platform Notes

Silverlight for Windows Phone Silverlight for Windows Phone

 This member has a SecurityCriticalAttribute attribute on Silverlight for Windows Phone, because the attribute was present in Silverlight 3. This attribute restricts this member to internal use. Application code that uses this member throws a MethodAccessException.

Version Information

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

Platforms

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

See Also

Reference