开发者

How to read the .setting file?

开发者 https://www.devze.com 2023-03-11 08:24 出处:网络
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.c

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号