views:

161

answers:

4

I have a low quantity of data to persist in my .NET app. For example, the file that has been opened last time when the user was around. What is the best practice to persist and retrieve information like that? A code sample would be appreciated.

+3  A: 

See this question for some suggestions.

http://stackoverflow.com/questions/453161/best-pratice-to-save-application-settings-in-windows-application

JTA
+1  A: 

James's direction is helpful, but bear in mind , what type of application? there are differences between web apps and windows apps. Look at cookies, session state appropriate for web apps.

A useful way is to extend the profile provider

http://msdn.microsoft.com/en-us/library/taab950e.aspx

The profile provider remembers info after session has ended. Alternatively, sql server provides great permanent storage for creating your own state handler

Stuart
A: 

.NET has this built in go to your project settings you can have per user and per aplication settings persisted extremely easily.

PeteT
A little code sample on how to read/write settings in runtime would have made your answer perfect. But without that it is not helpful.
Mr. Lame
+1  A: 

I've struggled with this question for a very long time, but finally ive found a solution that works superb for me.

Create a settings class containing all simple settings (i.e. one value) Create a class for every setting that has to return multilpe values

Find yourself a nice ORM (i like xpo very much, but bear in mind that that is a commercial solution).

The ORM does all the work (at least, if you have a nice one).

Henri