How to maintain user.config settings when upgrading

http://bytes.com/topic/c-sharp/answers/522191-how-maintain-user-config-settings-when-upgrading

Add a Setting to your project called ApplicationVersion, then use code like

the following in the startup of your applicaiton:

System.Reflection.Assembly a =
System.Reflection.Assembly.GetExecutingAssembly();
Version appVersion = a.GetName().Version;
string appVersionString = appVersion.ToString();

if (Properties.Settings.Default.ApplicationVersion != appVersion.ToString())
{
Properties.Settings.Default.Upgrade();
Properties.Settings.Default.ApplicationVersion = appVersionString;
}
發佈了51 篇原創文章 · 獲贊 17 · 訪問量 17萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章