I guess technically it is considered a sectionGroup.
In this part of my app.config I declare my sectionGroup
Code:
<configSections>
<sectionGroup name="SerialPort">
<section name="SerialPortInformation" type="Scale_Simulator.SerialPortConfigHandler,Scale Simulator"/>
</sectionGroup>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="Scale_Simulator.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
</configSections>
Here is where I set the values
Code:
<SerialPort>
<SerialPortInformation>
<port></port>
<baudrate></baudrate>
<databits></databits>
<parity></parity>
<stopbits></stopbits>
<flow></flow>
</SerialPortInformation>
</SerialPort>
When you first start the program a serial port won't be setup that is why they are empty.
What I have so far for saving is this
Code:
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
config.GetSection("SerialPort/SerialPortInformation").SectionInformation.SetRawXml("<SerialPortInformation>" + "\r\n" + "<port>" + cboPort.Text + "</port>" + "\r\n" + "<baudrate>" + cbobaudRate.Text + "</baudrate>" + "\r\n" + "<databits>" + cboDataBits.Text + "</databits>" + "\r\n" + "<parity>" + cboParity.Text + "</parity>" + "\r\n" + "<stopbits>" + cboStopBits.Text + "</stopbits>" + "\r\n" + "<flow>" + cboHandShake.Text + "</flow>" + "\r\n" + "</SerialPortInformation>");
config.Save(ConfigurationSaveMode.Full, true);
ConfigurationSection mysection = config.GetSection("SerialPort/SerialPortInformation");
The information is not saving to the file.
Is there a better way to do this????
thanks,
-zd