How to obtain the original value of user settings?

  • Thread starter Thread starter Terry
  • Start date Start date
T

Terry

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,

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
 
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
 
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.
 
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.
 
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.
 
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.
 
Back
Top