升级Windows应用程序时如何保留旧的本地设置数据?

时间:2016-05-10 13:02:56

标签: c#

此问题将继续How to keep Settings details in Visual Studio application?票证。

我试过跟随但是它将我的旧LocalSetting数据设置为空白。 Program.cs的

//get current version which is 1.1.0 after upgrade
string tempVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
tempVersion = tempVersion.Remove(tempVersion.Length - 2);
//tempVersion = 1.1.0

//it will check whether is new version installed
//Settings.Default.ProductCurrentVersion = 1.0.0. So, it will called
if (Settings.Default.ProductCurrentVersion != tempVersion)
{
    MessageBox.Show("New Version: " +tempVersion);
    MessageBox.Show("Old Version: " +Settings.Default.ProductCurrentVersion);
    Settings.Default.Upgrade();
    Settings.Default.Save();
    //Local Settings data will be blank here.
}

有人可以提出我在这里缺少的东西吗?

0 个答案:

没有答案