BlackWaspTM

This web site uses cookies. By using the site you accept the cookie policy.This message is for compliance with the UK ICO law.

System Information
.NET 1.1+

Identifying System Folders

The Microsoft Windows environment includes many special folders, such as the folders for the desktop, music and pictures as well as the program files and system directories. These folders do not have fixed paths so they must be accessed correctly.

Environment Class

The Environment class is a standard class within the System namespace. It provides information relating to the current Windows environment. The Environment class contains a static method named GetFolderPath that allows you to determine the location of one of many special folders.

The GetFolderPath method requires a single parameter that identifies the system folder to be found. This parameter uses the SpecialFolder enumeration, which contains the list of directories that may be identified. For example, the following code displays the path to the user's "desktop" folder.

string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
Console.WriteLine(path);

SpecialFolder Constants

The SpecialFolder enumeration contains constants for many useful system folders. The following table lists the constants and describes their usage with the GetFolderPath method.

ConstantDescription
ApplicationDataReturns the folder that contains the application-specific data that is held in the user's roaming profile. This information is transferred to a network server and moved between machines when roaming profiles are in use.
CommonApplicationDataReturns the folder that contains application-specific data that is shared by all users of the computer.
CommonProgramFilesReturns the folder that is used for common program components that are shared by multiple applications.
CookiesReturns the folder that holds web browser cookies.
DesktopReturns the logical folder location of the desktop.
DesktopDirectoryReturns the physical folder location of the desktop.
FavoritesReturns that folder that contains the user's favourite items, including web site bookmarks.
HistoryReturns the folder that holds the user's Internet browsing history.
InternetCacheReturns the folder that contains the user's temporary Internet files.
LocalApplicationDataReturns the folder that contains application-specific data that is held in the user's local profile. This information is not included in the roaming profile.
MyComputerReturns the location of the "My Computer" folder. This is always an empty string as there is no physical location for My "Computer".
MyMusicReturns the location of the user's "My Music" folder.
MyPicturesReturns the location of the user's "My Computer" folder.
PersonalReturns the user's personal document folder. This is generally the same as the "My Documents" folder.
ProgramFilesReturns the standard location for installed program files.
ProgramsReturns the path to the Programs folder of the user's Start menu.
MyDocumentsOnly available in .NET framework 2.0 and later, this returns the location of the user's "My Documents" directory.
RecentReturns the folder that contains shortcuts to the user's recently opened files.
SendToReturns the folder that contains items for the "Send To" menu.
StartMenuReturns the folder that contains the user's Start Menu items.
StartupReturns the folder containing shortcuts to programs that are launched automatically at start-up.
SystemReturns the folder that contains the Microsoft Windows system files.
TemplatesReturns the folder to be used to hold standard document templates.
16 February 2008