更改App.config [英] change App.config
问题描述
在我的C#桌面应用程序中,我想在运行时更改app.config文件中的密钥.
如何在运行时更改此值?
Regrads
Hari
In my c# desktop application i want to change key in my app.config file at runtime.
How can i change this value in runtime?
Regrads
Hari
推荐答案
如果我理解正确,则您有一个应用程序设置文件,并且希望在运行时更改密钥.您是否尝试过:
if I understand correctly, you have an application settings file and you wish to change a key at runtime. Have you tried this:
System.Configuration.ConfigurationSettings.AppSettings.Set(名称,值);
System.Configuration.ConfigurationSettings.AppSettings.Set(name, value);
http://msdn2.microsoft.com/en-us/library/system.configuration.configurationsettings.aspx
http://msdn2.microsoft.com/en-us/library/system.configuration.configurationsettings_properties.aspx
http://msdn2.microsoft.com/en-us/library/system.configuration.configurationsettings.appsettings.aspx
但是我认为在.NET 2.0及更高版本中实际上已经过时了.
however I think doing this approach is actually obsolete in .NET 2.0 and higher.
看看这个:
,然后继续介绍如何创建应用程序设置,然后您可以为应用程序设置属性设置所需的值.
and follow on how to create application settings and from this you can then set the values you want to for your application settings properties.
对不起,我无法提供进一步的帮助,但是我希望这会在某种程度上对您有所帮助
sorry I Couldnt have been of further assistance however I hope this helps you in some way
这篇关于更改App.config的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!