安装驱时显示section is isnoneemptyy怎么办

【图文】2014年秋新版人教版九年级英语unit 4 Section A 2a-2c课件_百度文库
两大类热门资源免费畅读
续费一年阅读会员,立省24元!
2014年秋新版人教版九年级英语unit 4 Section A 2a-2c课件
大小:1.51MB
登录百度文库,专享文档复制特权,财富值每天免费拿!
你可能喜欢Access denied |
used Cloudflare to restrict access
Please enable cookies.
What happened?
The owner of this website () has banned your access based on your browser's signature (3c62b-ua98).c# - ConfigurationManager.AppSettings - How to modify and save? - Stack Overflow
Learn, Share, Build
Each month, over 50 million developers come to Stack Overflow to learn, share their knowledge, and build their careers.
Join the world’s largest developer community.
Display name
Email address
By registering, you agree to the
It might sound too trival to ask and I do the same thing as suggested in articles, yet it doesn't work as expected. Hope someone can point me to the right direction.
I would like to save the usersettings per AppSettings.
Once the Winform is closed I trigger this:
conf.Configuration config =
ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
if (ConfigurationManager.AppSettings["IntegrateWithPerforce"] != null)
ConfigurationManager.AppSettings["IntegrateWithPerforce"] =
e.Payload.IntegrateCheckBox.ToString();
config.AppSettings.Settings.Add("IntegrateWithPerforce",
e.Payload.IntegrateCheckBox.ToString());
config.Save(ConfigurationSaveMode.Modified);
So the first time when the entry doesnt exist yet, it would simply create it, otherwise it would modify the existing entry.
However this doesn't save.
1) What am I doing wrong?
2) Where am I expecting the usersettings for App settings to be saved again? Is it in the Debug folder or in C:\Documents and Settings\USERNAME\Local Settings\Application Data folder?
3,960124991
22.5k52171329
Perhaps you should look at adding a Settings File. (e.g. App.Settings)
Creating this file will allow you to do the following:
string mysetting = App.Default.MyS
App.Default.MySetting = "my new setting";
This means you can edit and then change items, where the items are strongly typed, and best of all... you don't have to touch any xml before you deploy!
The result is a Application or User contextual setting.
Have a look in the "add new item" menu for the setting file.
7,48273346
On how to change values in appSettings section in your app.config file:
config.AppSettings.Settings.Remove(key);
config.AppSettings.Settings.Add(key, value);
does the job.
Of course better practice is Settings class but it depends on what are you after.
1,27952035
I know I'm late :) But this how i do it:
public static void AddOrUpdateAppSettings(string key, string value)
var configFile = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
var settings = configFile.AppSettings.S
if (settings[key] == null)
settings.Add(key, value);
settings[key].Value =
configFile.Save(ConfigurationSaveMode.Modified);
ConfigurationManager.RefreshSection(configFile.AppSettings.SectionInformation.Name);
catch (ConfigurationErrorsException)
Console.WriteLine("Error writing app settings");
For more information look at
8,07595487
Prefer &appSettings& to &customUserSetting& section.
It is much easier to read AND write with (Web)ConfigurationManager.
ConfigurationSection, ConfigurationElement and ConfigurationElementCollection require you to derive custom classes and implement custom ConfigurationProperty properties.
Way too much for mere everyday mortals IMO.
Here is an example of reading and writing to web.config:
using System.Web.C
using System.C
Configuration config = WebConfigurationManager.OpenWebConfiguration("/");
string oldValue = config.AppSettings.Settings["SomeKey"].V
config.AppSettings.Settings["SomeKey"].Value = "NewValue";
config.Save(ConfigurationSaveMode.Modified);
&appSettings&
&add key="SomeKey" value="oldValue" /&
&/appSettings&
&appSettings&
&add key="SomeKey" value="newValue" /&
&/appSettings&
6,45722348
as the base question is about win forms here is the solution :
( I just changed the code by user1032413 to rflect windowsForms settings
if it's a new key :
Configuration config = configurationManager.OpenExeConfiguration(Application.ExecutablePath);
config.AppSettings.Settings.Add("Key","Value");
config.Save(ConfigurationSaveMode.Modified);
if the key already exists :
Configuration config = ConfigurationManager.OpenExeConfiguration(Application.ExecutablePath);
config.AppSettings.Settings["Key"].Value="Value";
config.Save(ConfigurationSaveMode.Modified);
Try adding this after your save call.
ConfigurationManager.RefreshSection( "appSettings" );
2,80511216
Remember that ConfigurationManager uses only one app.config - one that is in startup project.
If you put some app.config to a solution A and make a reference to it from another solution B then if you run B, app.config from A will be ignored.
So for example unit test project should have their own app.config.
14.3k94463
I think the problem is that in the debug visual studio don't use the normal exeName.
it use indtead "NameApplication".host.exe
so the name of the config file is
"NameApplication".host.exe.config
"NameApplication".exe.config
and after the application close - it return to the back app.config
so if you check the wrong file
or you check on the wrong time you will see that nothing changed.
void ApplySettings(string key, string value)
var configFile = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
var settings = configFile.AppSettings.S
if (settings[key] == null)
settings.Add(key, value);
settings[key].Value =
configFile.Save(ConfigurationSaveMode.Modified);
ConfigurationManager.RefreshSection(configFile.AppSettings.SectionInformation.Name);
You can change it manually:
private void UpdateConfigFile(string appConfigPath, string key, string value)
var appConfigContent = File.ReadAllText(appConfigPath);
var searchedString = $"&add key=\"{key}\" value=\"";
var index = appConfigContent.IndexOf(searchedString) + searchedString.L
var currentValue = appConfigContent.Substring(index, appConfigContent.IndexOf("\"", index) - index);
var newContent = appConfigContent.Replace($"{searchedString}{currentValue}\"", $"{searchedString}{newValue}\"");
File.WriteAllText(appConfigPath, newContent);
Your Answer
Sign up or
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Post as a guest
By posting your answer, you agree to the
Not the answer you're looking for?
Browse other questions tagged
The week's top questions and answers
Important community announcements
Questions that need answers
By subscribing, you agree to the
Stack Overflow works best with JavaScript enabledAccess denied | linux.die.net used Cloudflare to restrict access
Please enable cookies.
What happened?
The owner of this website (linux.die.net) has banned your access based on your browser's signature (3cd5396-ua98).}

我要回帖

更多关于 document is empty 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信