How to decide where to store the state for each user? Registry? Application data? Isolated Storage?

When should the Windows registry be used for status for each user, and when should we use the file system, especially the user's AppData folder? (e.g. C: \ Users \ USERNAME \ AppData). Where is the isolated storage located?

Is there a pretty solid rule, or is it just a fuzzy thing, for example, "use the registry until it becomes too large to store data in the registry." or "use whatever you want to use."

Are there any Windows logo requirements that affect the solution?

If I use the AppData directory, how do I choose between Local, Roaming and LocalLow?

edit: I just noticed these similar questions:

  • When and why to store data in the registry?
  • Registry file for Ini to save user application settings .

I will summarize the answers.

+19
c # windows winforms wpf registry
May 19 '09 at 12:36
source share
4 answers

If you have a small number of key / value pairs and the values ​​are small, the registry is very large - and you do not need to deploy xcopy and then use the registry (I know this is not accurate, but it is usually obvious when working with the registry becomes a pain).

If you want xcopy deployment, the data should be in the same folder as the program, but the program may be located somewhere in the AppData folder, it should not be under the "program files".

Use isolated storage only when you need it or need to use it - for example, ClickOnce.

Otherwise, use AppData \ Roaming, use Local or LocalLow only if you have a good reason.

EDIT: here is the difference between Roaming, Local and LocalLow:

Windows has a little-known feature called “roaming profiles,” the general idea is that in a corporate environment with this feature, every user can use any computer.

When a user logs in to his personal settings, boots from the server, and when he logs out, his settings are downloaded back to the server (the actual process is more complicated, obviously).

Files in the user's Roaming folder in Vista or Application data in XP are moved together with the user - therefore, any settings and data should be stored there.

There are no files under “Local” and “LocalLow” in Vista and “Local Settings” in XP, so this is a good place for temp files, things associated with a specific computer or data that can be recounted.

In Vista, as part of the new security features that we all know and love, you can have programs that work in "low integrity" mode (for example, IE in protected mode), these programs work with reduced privileges and cannot access files in user profile - excluding files in the "LocalLow" folder.

So, in conclusion, the files stored in "LocalLow" are inherently unsafe, and the files in the "Local" / "Local settings" are probably not available in some large companies, so if you have no good reason and know exactly that you perform Roaming / Application Data.

+11
May 19, '09 at 14:34
source share

Don't clutter your registry, thanks.

Use isolated storage for what it is intended.

See Was a Windows registry a good idea? Jeffs Blog ...

+5
May 19, '09 at 15:43
source share

You might want to consider Isolated Storage .

+4
May 19 '09 at 12:37
source share

I don’t know if there is a solid rule, but keep in mind that the registry is transactive - it is safe for simultaneous read / write operations. Thus, if your user data can be written in multiple threads at run time (or if you have multiple exe instances in your product package), consider using a registry.

History: One of the reasons (as I heard) that MS moved from .ini files to the registry was an attempt to try to solve the problem of parallel access.

.Net (view) returned to the .ini files as xml.config files, however these configuration files should not be written at run time (or at least not if there is a possibility of simultaneous authors / readers).

Additional information: http://blogs.msdn.com/oldnewthing/archive/2007/11/26/6523907.aspx

+1
May 19 '09 at 1:55
source share



All Articles