Windows Develop Bookmark and Share   
 index > Windows Forms General > Creating sections in app.config on fly
 

Creating sections in app.config on fly

Hi,

My C# windows application has following app.config settings:

configuration>
<
configSections>
<
sectionGroup name="AppSec">
<
section name="Section1" type="System.Configuration.NameValueSectionHandler"/>
<
section name="Section2" type="System.Configuration.NameValueSectionHandler"/>
</
sectionGroup>
</configSections>

<AppSec>
<
Section1>
<
add key="key1" value="value1" />
</
Section1>

<Section2>
<
add key="key1" value="value1" />
</
Section2>
</
AppSec>

I have following questions:
1. How can I create sectionGroup and sections on fly (before application load) incase user either delete app.config file or these information?

2. Is it possible to add multiple attributes/value like<add key="key1" value="value1"value1="value1"value2="value1"/>

Thanks

ptenter  Sunday, March 01, 2009 3:30 PM
1. The best way to deal with your user monkeying with the .config file is to crash your program. That puts a quick end to any future attempts. Trying to do something reasonable in unreasonable circumstances will put the problem on your plate, not where it belongs.
2. No.

Hans Passant.
nobugz  Sunday, March 01, 2009 4:22 PM
1. The best way to deal with your user monkeying with the .config file is to crash your program. That puts a quick end to any future attempts. Trying to do something reasonable in unreasonable circumstances will put the problem on your plate, not where it belongs.
2. No.

Hans Passant.
nobugz  Sunday, March 01, 2009 4:22 PM

1. Incase your applicationusing<appSettings>and user either delete file or delete<appSettings>, you cancreate those settings. Right? Can't I apply same for first question?

2. Can't I create customized settings to store multiple values?E.g. <Link Name="Page" Href="Styles/Page.css" Image="/Image/"/>

Thanks

ptenter  Monday, March 02, 2009 3:47 AM

You can use google to search for other answers

Custom Search

More Threads

• how to disable "X" button in the form
• Way to detect non alphabet font types for display in a control
• Need to set form vertical scroll bar according to cursor position
• Experts opinion needed!
• Need suggestion
• my .exe file is not running ouside bin folder?
• ComboBox. Font of SuggestAppend list
• Problem in saving/select Rich Text in MySql Database.
• TreeView image quality
• How to make the webbrowser control open links in same window instead of popups