以下是app.config或web.config的定义,定义了一个参数,键为isinit,值为false
以下是读和写config文件的方法定义:
写入:
internal void settingApp_write(string key, string val) { System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); config.AppSettings.Settings["IsInit"].Value = val; config.Save(ConfigurationSaveMode.Modified); ConfigurationManager.RefreshSection("appSettings"); }
登录后复制
读取:
internal string settingApp_read(string key) { var val = ConfigurationManager.AppSettings[key]; return val; }
登录后复制
使用方法:
写入测试:
settingApp_write(“IsInit”,”true”);
取出测试:
var setting = settingApp_read(“Isinit”);
此级别的修改是项目级别的config文件修改,也就是你最终程序Bin目录下的那个config文件的操作。
更多C#操作config文件的具体方法相关文章请关注PHP中文网!
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至253000106@qq.com举报,一经查实,本站将立刻删除。
发布者:PHP中文网,转转请注明出处:https://www.chuangxiangniao.com/p/2553726.html