[英]How to prevent settings.settings file reset after each new installation
So I have WPF
application
and I am using settings.settings
file to save several settings for example specific Path
that the user need to set and I am also create a exe
installation file using Advanced installer
and after install new application
version all the application files (include the application exe
file) replaced with the new version and in such case all settings.settings
variables reset and I want to prevent it.所以我有
WPF
application
,我正在使用settings.settings
文件来保存几个设置,例如用户需要设置的特定Path
,我还使用Advanced installer
创建一个exe
安装文件,并在安装新的application
版本后所有应用程序文件(包括应用程序exe
文件)替换为新版本,在这种情况下,所有settings.settings
变量都会重置,我想阻止它。
Any ideas ?有任何想法吗 ?
If I understand correct, when you upgrade your application you want your settings.settings file to be saved.如果我理解正确,当您升级应用程序时,您希望保存 settings.settings 文件。 If you don't want to use "Side by side install", you can do this:
如果您不想使用“并排安装”,您可以这样做:
xcopy \/Y %1 %2<\/code>
您可以在 google 上找到如何在 .bat 中复制文件,这是xcopy \/Y %1 %2<\/code>
<\/li><\/ol> If this is what you need and you can't implement it, just tell me and I will try to help you.
如果这是您需要的,但您无法实施,请告诉我,我会尽力帮助您。
"
For Windows Forms apps I use code like this in my main form, after the call to InitializeComponent().对于 Windows 窗体应用程序,在调用 InitializeComponent() 之后,我在主窗体中使用这样的代码。 It copies the settings from the previous version the first time the new version runs.
它会在新版本第一次运行时复制以前版本的设置。
if (Properties.Settings.Default.FirstTimeRunningThisVersion)
{
Properties.Settings.Default.Upgrade();
Properties.Settings.Default.FirstTimeRunningThisVersion=false;
Properties.Settings.Default.Save();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.