How to obtain the original value of user settings?

How to obtain the original value of user settings?

Post by VGVycn » Sun, 10 May 2009 03:00:01


I have a number of user settings that are grouped by functionality. I would
like to provide the user with the ability to 'restore factory defaults' for
these groups. I had thought that the My.MySettings.Default.SettingName would
provide me with the original value, but it returns the last saved value. Now
I know the original settings are somewhere, but is there a way to get at
them?
--
Terry
 
 
 

How to obtain the original value of user settings?

Post by Cor Ligthe » Sun, 10 May 2009 15:14:04

Terry,

Maybe I am the only one what is the answer to your puzzle, can you give us a
hint and tell about what original user setting you are talking.

One guess, are that the one which are used by the Setup of the OS?

Cor

 
 
 

How to obtain the original value of user settings?

Post by James Hah » Sun, 10 May 2009 17:10:17

You could do what the IDE does, and delete the settings file.
 
 
 

How to obtain the original value of user settings?

Post by VGVycn » Sun, 10 May 2009 22:46:05

Hi Cor,
I am sorry I was not clear enough. I am talking about all the settings
(user) I have defined through the IDE and are originally stored in the
<AppName>.exe.config file. It would be nice not to have to tell the user to
go and delete his user.cofig file if he wants to to back to the 'original'
settings. Obviously these original settings are somewhere in the .exe since
they are what gets used if the user.config file is deleted or when the app is
first run or if the user has not changed any settings. While the
My.MySettings.Default.<settingName> is usefull to get back to values before
the current session, being able to get back the values I shipped the
application with would also be useful. Of course, I could store them all
twice (a second time at the Application Level) and use those values to
restore to, but that just seems like a waste. Mybe it is possible through
reflection.
--
Terry
 
 
 

How to obtain the original value of user settings?

Post by Cor Ligthe » Mon, 11 May 2009 02:07:28

Terry,

Why not simple copying the config.sys file at every start and then as the
user wants them back set that back.

I never did that and I am not aware what this does mean for the security
settings.
But I assume that it should not be a big job and maybe even possible with
the File class.

http://www.yqcomputer.com/

Cor
 
 
 

How to obtain the original value of user settings?

Post by James Hah » Mon, 11 May 2009 08:59:14

I doubt there's a need to ask the user to delete the file - see if you can
delete it from within the app when the user chooses the 'restore to factory'
option.

Although it sounds like the long way around, my preference would be to
provide the default settings from within the app and simply overwrite the
current settings with the 'factory deafults' when the user selects the
option. This is what I always do for the screen location settings - it is
too easy for a user to locate a window off the screen and lose it, so I
provide an option to restore all windows to their default locations. But to
do it without disturbing other settings means that I have to build those
defaults into the app. Once there is the need to do that for some of the
settings, it's easy to extend the option to give the user 2 or 3 levels of
restore.