On Window 7, 8 and 10 I want my app to store data in shared location so all users who run the app on the PC will access the same data. The data are readable/writable. What location should I use?
The AppData folder for each user account can be found in the user's directory. For example, if your user name is Joe, you'll find your AppData folder at C:\Users\Joe\AppData by default.
Once you've logged into your Windows machine, you can find all of the data on the computer's “Local Disk (C:) > Users.” When working with corporate machines, it's normal to see multiple users, including Administrator or IT users.
Handles storage of structured user data, including contact info, calendars, messages, and other content. If you stop or disable this service, apps that use this data might not work correctly.
Windows has funny rules regarding program' shared data.
C:\Program Files
" and "C:\Program Files (x86)
") is intended for immutable (read-only) program data and executable files - consequently files here require administrative permissions to edit. Thus it makes it useful for important files that should not be compromised (e.g. your main executable). This is why installers run with elevated permissions. There is a downside in that if your program has an auto-update mechanism then that too needs to run elevated.C:\ProgramData
on Windows Vista and later, or C:\Documents and Settings\All Users\Application Data
) is intended for mutable program data - you don't need administrative permissions to create files in this folder, except that once a file has been created only the user that originally created that file can subsequently edit it (though everyone can read it). This is the special CREATOR OWNER
permission.
C:\Users\(you)\AppData\Local
and C:\Users\(you)\AppData\Roaming
) is user-specific and is intended for user-specific settings, configuration and data. The Local
version should be used for machine-specific settings that shouldn't roam if the user is using Roaming Profiles, such as data caches (e.g. a browser cache).So in your case ProgramData
looks ideal, but you need to be careful about the default CREATOR OWNER
rules - but there's a workaround: your program's installer (which would run as admin) has the ability to change the ACL permissions on its ProgramData subdirectory to allow other users to edit files. I suggest granting the Users
group permission instead of Everyone
to prevent possible remote attacks and modifications by unauthenticated users.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With