May i know how to check the connectionstrin开发者_StackOverflow社区g from the .setting file when my apps load? I want to make my apps to read connectionstring from .setting file instead from the app.config. Then if there is no connectionstring in .setting file, then i should display a dialog to enter the server name and runtime write to the .setting file.
How do i achieve the function above for my clickonce deployment which targetting multiple computers. Could you advice?
You just need to use the following to read, assuming you have a setting called ConnectString
string conString = Properties.Settings.Default.ConnectString;
To be able to write back to the .setting you also need to ensure you set it as a user "scope" setting varible and then simply set the property
Properties.Settings.Default.ConnectString = "new connection string";
and to persist the change use
Properties.Settings.Default.Save();
You could read more about it here
Hope this helps
You can use Properties.Settings.Default.MySetting; to read from settings.
精彩评论