Environment.GetFolderPath Method

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

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

public static string GetFolderPath (
	SpecialFolder folder
public static String GetFolderPath (
	SpecialFolder folder
public static function GetFolderPath (
	folder : SpecialFolder
) : String



An enumerated constant that identifies a system special folder.

Return Value

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.

Exception typeCondition


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

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 at http://msdn.microsoft.com/library/en-us/shellcc/platform/Shell/reference/enums/csidl.asp.

// Sample for the Environment.GetFolderPath method
using System;

class Sample 
    public static void Main() 
    Console.WriteLine("GetFolderPath: {0}", 
This example produces the following results:

GetFolderPath: C:\WINNT\System32

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0

Community Additions