views:

227

answers:

5

Could somebody point me to a document which lists all the standard file locations in windows and what one should and shouldn't use them for. Something like

User Application Data -> %USERDIR%/AppData/Local/%VENDOR%/%APPLICATION%

and so forth.

+6  A: 

Big Disclaimer

Do not ever use the hard paths to these locations. Only use the provided APIs (whether those APIs be standard Win32 APIs, the .NET APIs, whatever) to access them. Otherwise you run the risk of breaking on different versions and languages of Windows.

And that's a real risk -- they've changed those locations at least four times -- and that's just in what I can recall off the top of my head! Not to mention roaming profiles and other fun weirdness that can crop up.

Now that the big disclaimer is out of the way, where's the list? Wikipedia has it. Take some of the "first-appeared-in" with a grain of salt; I'm 90% sure I've seen some of these appear earlier than is claimed. I have shamelessly cut-and-pasted-and-reformatted their content below:

  • Application Data
    • Per-user application-specific files
    • %USERPROFILE%\Application Data
    • First appeared in Windows 98
  • Cookies
    • Internet Explorer browser cookies
    • %USERPROFILE%\Cookies
    • First appeared in Windows 98
  • Desktop Directory
    • Files stored on the user's desktop
    • %USERPROFILE%\Desktop
    • First appeared in Windows 95
  • Favorites
    • User's Favorites
    • %USERPROFILE%\Favorites
    • First appeared in Windows 98
  • Fonts
    • Container folder for installed fonts
    • %windir%\Fonts
    • First appeared in Windows XP
  • History
    • User-specific browser history
    • %USERPROFILE%\Local Settings\History
    • First appeared in Windows 98
  • Internet Cache
    • User-specific Temporary Internet Files
    • %USERPROFILE%\Local Settings\Temporary Internet Files
    • First appeared in Windows 98
  • Local Application Data
    • User-specific and computer-specific application settings
    • %USERPROFILE%\Local Settings\Application Data
    • First appeared in Windows 2000/ME
  • My Documents
    • User's documents
    • %USERPROFILE%\My Documents (WinNT line)
    • C:\My Documents (Win98-ME)
    • First appeared in Windows 98
  • My Music
    • User's music
    • %USERPROFILE%\My Documents\My Music
    • First appeared in Windows XP
  • My Pictures
    • User's pictures
    • %USERPROFILE%\My Documents\My Pictures
    • First appeared in Windows XP
  • My Videos
    • User's video files
    • %USERPROFILE%\My Documents\My Videos
    • First appeared in Windows XP
  • Programs
    • User-specific "(All) Programs" groups and icons
    • %USERPROFILE%\Start Menu\Programs
    • First appeared in Windows 95
  • Recent
    • User-specific "My Recent Documents"
    • %USERPROFILE%\Recent
    • 98
  • Send To
    • User-specific "Send To" menu items
    • %USERPROFILE%\SendTo
    • First appeared in Windows 98
  • Start Menu
    • User-specific "Start Menu" items
    • %USERPROFILE%\Start Menu
    • First appeared in Windows 98
  • System
    • The Windows system directory
    • %windir%\system32
    • First appeared in Windows 2000
  • Saved Games
    • User's Saved Games
    • %USERPROFILE%\saved games
    • First appeared in Windows Vista
  • Templates
    • User-specific document templates
    • %USERPROFILE%\Templates
    • First appeared in Windows 98
John Rudy
A: 

Never use the hardcoded values. Not only are their APIs to retrieve them, but some also have environment variables.

For instance, Windows XP has these environment variables:

ALLUSERSPROFILE=C:\Documents and Settings\All Users
APPDATA=C:\Documents and Settings\[username]\Application Data
CommonProgramFiles=C:\Program Files\Common Files
HOMEDRIVE=C:
HOMEPATH=\Documents and Settings\[username]
ProgramFiles=C:\Program Files
SystemDrive=C:
SystemRoot=C:\WINDOWS
TEMP=%APPDATA%\Local Settings\Temp
TMP=%APPDATA%\Local Settings\Temp
USERPROFILE=C:\Documents and Settings\[username]
windir=C:\WINDOWS

Vista adds a few new environment variables, such as LOCALAPPDATA, ProgramData, and Public

R. Bemrose
+5  A: 

The KnownFolderID on MSDN is the official list.

Look at SHGetFolderlocation() (XP) or SHGetKnownFolderIDList() (Vista/W7) on how to get the location of these folders properly.

Marcus Lindblom
+1 for the proper Win32 APIs. :)
John Rudy
+2  A: 

A lot of the information can be found in the MSDN page for Special Folders: http://msdn.microsoft.com/en-us/library/system.environment.specialfolder.aspx. It's useful information in addition to John's answer

Agent_9191
+1 for the MSDN link
John Rudy
A: 

a lot of this changed with vista/7. see http://www.online-tech-tips.com/windows-vista/move-my-pictures-to-different-location/

Jim Michaels