1

I'm distributing a wpf .net executable to internal customers. I'm saving their preferences to a configuration file that's automatically written to a unique folder in the Temp directory, using the .NET Configuration class. When I distribute the newest .exe, it creates a new unique folder under Temp, and starts the configuration settings from scratch. There are two config files: 1 for global app settings, and 1 for each specific data set.

How can I make the settings from the previous version get moved into the new version, so the users don't have to lose their settings?

4

1 回答 1

0

我的解决方案:在启动时,我查看 %localappdata% 下保存配置文件的目录。我检查版本号以查看当前版本是否比已保存的任何其他版本更新。然后我只是从旧目录复制到新目录。为了向后兼容,我无法从配置中删除任何旧设置;我只能弃用它们。此外,我无法在配置中将任何新设置标记为“必需”。

实际上,现在我正在输入这个,我意识到也许我没有找到更通用的方法的原因是因为配置系统无法知道你是否搞砸了与以前的可执行文件的向后兼容性。

于 2013-02-25T17:25:19.610 回答