dominicwong
asked on
Trouble with persisting user settings when install new version
Hi experts
I have some trouble in restoring persisted user config settings when installing a new version of my C# .NET application.
I have the following lines right at the beginning of my main program:
The old settings was kept in the file "user.config" at the location:
C:\Users\dwong\AppData\Loc al\Company \MyTool.ex e_Url_bp2u 4og4vwazxw bxllvfhrz3 ph3omcfd\1 .1.0.4
After installing the new version, I could see a new "user.config" at a new location:
C:\Users\dwong\AppData\Loc al\Company \MyTool.ex e_Url_pjgu dcgzuigkvo kmjnwldqae cw2hgaz5\1 .1.0.5
But the code above didn't copy the old user settings, could someone point to me where I might have done wrong.
FYI, I am using C#, .NET 3.5, Installer.
Thanks in advance.
I have some trouble in restoring persisted user config settings when installing a new version of my C# .NET application.
I have the following lines right at the beginning of my main program:
// if(Properties.Settings.Default.UpgradeSettings). Temporary took out for testing
{
Properties.Settings.Default.Upgrade();
Properties.Settings.Default.UpgradeSettings = false;
Properties.Settings.Default.Save();
}
The old settings was kept in the file "user.config" at the location:
C:\Users\dwong\AppData\Loc
After installing the new version, I could see a new "user.config" at a new location:
C:\Users\dwong\AppData\Loc
But the code above didn't copy the old user settings, could someone point to me where I might have done wrong.
FYI, I am using C#, .NET 3.5, Installer.
Thanks in advance.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Mind if you can share your test project for testing purpose.
Just want to give it try to experience same weird issue.
Just want to give it try to experience same weird issue.
ASKER
Thanks Vikram Singh Saini.
The test project actually works fine. It generated the same hash for every new version, and put the 'user.config' for any subsequent newer versions under the same directory.
C:\Users\{User}\AppData\Lo cal\{Compa nyName}\{E xecutableN ame}_Url_hash\1.0.0.x
The weird issue is, therefore, not with the test project but rather with my original project which generated a different hash every time.
The test project actually works fine. It generated the same hash for every new version, and put the 'user.config' for any subsequent newer versions under the same directory.
C:\Users\{User}\AppData\Lo
The weird issue is, therefore, not with the test project but rather with my original project which generated a different hash every time.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks Vikram Singh Saini for your offer to help.
ASKER
I'd taken a look at the link and the approach is similar to what I did.
I'd created an empty project, and retested my original approach. The issue seems to be related to the different directory path that was created in the 'AppData\Local' directory by my original program:
C:\Users\dwong\AppData\Loc
C:\Users\dwong\AppData\Loc
My new empty test project put all the new versions under the same directory as:
C:\Users\dwong\AppData\Loc
C:\Users\dwong\AppData\Loc
C:\Users\dwong\AppData\Loc
C:\Users\dwong\AppData\Loc
The question is what triggers my original program to create a different path everytime? Any idea?
Thanks in advanec