问题描述
我已经阅读了关于这个主题的众多问题,甚至发布了我自己的一个(在StackOverflow)试图到底这一点([ 我的
以前的问题 ])。不幸的是,他们都没有回答我的问题。
I have read the numerous questions here on this topic and even posted one of my own(at StackOverflow) trying to get to the bottom of this([My Previous Question]). Unfortunately, none of them answer my question.
每当我通过ClickOnce部署更新时,我的`.Settings`文件都会被重置。我认为ClickOnce应该为我处理这类事情()但是因为它似乎没有,所以我使用设置标志实现`.Upgrade()`,如下所示:
My `.Settings` file get's reset whenever I deploy an update through ClickOnce. I thought ClickOnce was supposed to handle this sort of thing for me(See Here) but since it seems no, so I implemented the `.Upgrade()` with a Settings Flag like so:
if (Settings.Default.MustUpgradeSettings)
{
Settings.Default.Upgrade();
Settings.Default.MustUpgradeSettings = false;
Settings.Default.Save();
}
推荐答案
每当我通过ClickOnce部署更新时,我的`.Settings`文件都会重置。 我认为ClickOnce应该为我处理这类事情()
但是因为它似乎没有,所以我使用设置标志实现了`.Upgrade()`,如下所示:
My `.Settings` file get's reset whenever I deploy an update through ClickOnce. I thought ClickOnce was supposed to handle this sort of thing for me(See Here) but since it seems no, so I implemented the `.Upgrade()` with a Settings Flag like so:
if (Settings.Default.MustUpgradeSettings)
{
Settings.Default.Upgrade();
Settings.Default.MustUpgradeSettings = false;
Settings.Default.Save();
}
这篇关于设置文件在ClickOnce更新时丢失值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!