10

How do I decide which of my application's files go in Program Files (FOLDERID_ProgramFilesX64) and which go in ProgramData? (FOLDERID_ProgramData)? I don't understand what the reason is for splitting up my application's fixed files into these two categories or how I should decide which file goes in what.

For example - image files which my application displays, are they "program" or "data"?

Is there any problem with just putting everything under one or the other?

The application is installed for All Users and has no user-specific configuration files or data.

M.M
  • 138,810
  • 21
  • 208
  • 365
  • Note - my understanding from googling so far is that `ProgramData` actually means files which are not supposed to be changed by the application at runtime (although if the application also had files which do need to be changed at runtime, and not on a per-user basis, then the installer would have to set ACLs under ProgramData to allow this). – M.M Dec 16 '14 at 04:19
  • Files that are the same on every machine should go in Program Files. Global files that are generated at runtime rather than at installtime have to go in ProgramData, although this should be avoided unless it is absolutely necessary. Files that are different on each machine but are generated at installtime could go in either place, but ProgramData would probably be preferable. – Harry Johnston Dec 16 '14 at 07:21
  • It gets little use, nobody *really* wants to support an install where users can overwrite each other's files with no backup mechanism. Only practical for read-only files that are used by multiple programs or programs that run elevated. So useful if your image file is a big pretty image that multiple programs display in their splash screen for example. Tends to be abused by installers, some of them make the entire directory writable. – Hans Passant Dec 16 '14 at 09:51
  • @HansPassant: "little use" is relative I suppose, but there are quite a few mainstream products that use it; my machine has folders for Microsoft Help, Adobe Acrobat, Adobe AIR, Minitab, Firefox, Skype, and Symantec Endpoint Protection among others. I'm not saying they should, mind you, just that they do. – Harry Johnston Dec 16 '14 at 19:58

1 Answers1

11

Program Files is for executables and other static files that came as part of the installation. ProgramData is for user-agnostic data generated during execution such as shared cache, shared databases, shared settings, shared preferences, etc. User-specific data goes in the AppData folder. Note that these are for non-user-visible data. User-visible data belongs in the documents folder (or music, video, custom sibling folder, etc.).

Please see Special Folders and Custom Folders for a detailed explanation. Note that the terminology used varies slightly between the name used in the documentation here, the name of the folder, and the name used by various enumerations used to get these paths from the system.

James
  • 3,551
  • 1
  • 28
  • 38
  • 1
    As discussed on [this thread](http://stackoverflow.com/questions/10507233/how-to-write-to-the-common-application-data-folder) , ProgramData defaults to not being writable by the application at runtime in Windows 7. So the installer must do an ACL hack and give world-writable permissions to its folder under ProgramData; all of this suggests that actually it was not intended to be used the way you say, hence my confusion! – M.M Dec 16 '14 at 04:52
  • I've edited to clarify--ProgramData is for data that is shared across all user accounts. There's yet another location (AppData) for user-specific data. Please see the link I added for full details. Yes, lower-privilege users may not have rights to edit the shared data. – James Dec 16 '14 at 05:08
  • I still don't follow. If a non-admin user is running the application then is it expected the application asks for UAC elevation to write its shared cache? – M.M Dec 16 '14 at 05:20
  • Yes. Cache and settings that are shared across users are generally a rare thing. Since changing those could affect other users, UAC elevation is required. This is similar to the protections the OS puts in place to prevent one bad program from reading data from or writing data to another process. The separation of different types of data allows developers to decide which items should be shared and which ones should not. Cache can often contain user-specific data, which shouldn't be able to be read by other users. – James Dec 16 '14 at 05:34
  • The permissions on the ProgramData directory (and the default permissions on subdirectories) allow any user to create new directories and files. This means you can create a directory at runtime without elevation, so your installer does not need to do it for you. The default permissions on files allow anyone to read them but only the creator can write to them. The answer on the other thread is wrong. – Harry Johnston Dec 16 '14 at 07:28