Re: Best format for configuration file?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Cezary Nolewajka (c.nolewajka-no-sp-am-eh_at_no-sp-am-eh-mail.com)
Date: 02/06/04


Date: Fri, 6 Feb 2004 17:29:12 +0100

If you want to write to the config file from your application you cannot use
the app.config file.

I reckon the best and most flexible solution is XML Serialization. Moreover,
it has advantages towards flat <appSettings> element and it's subelements.

Using XML Serialization you can desing your own class with all application
settings you need and simply serialize/deserialize it into/from a file.

You gain read/write settings capabilities and more complex settings
structure including even arrays and nested elements.

You can go as far as:
<Settings>
    <Section1>
        <OptionName value="123" output="098324-2" />
        <OptionName value="kljewr" output="098324-2" />
        <OptionName value="-93mc[" output="098324-2" />
        <OptionName value="[apioewcr" output="098324-2" />
    </Section1>
    <Section2>
        <OptionName value="123" output="098324-2" />
        <OptionName value="kljewr" output="098324-2" />
        <OptionName value="-93mc[" output="098324-2" />
        <OptionName value="[apioewcr" output="098324-2" />
    </Section2>
    ...
</Settings>

-- 
Cezary Nolewajka
mailto:c.nolewajka-no-sp-am-eh@no-sp-am-eh-mail.com
remove all "no-sp-am-eh"s to reply
"Jimbo" <None> wrote in message
news:OhO0%23YL7DHA.1852@TK2MSFTNGP10.phx.gbl...
> What's the best format to save a configuration file?
> I'm currently using an INI extension and I write it like a normal ascii
> file. Is this the best way? I've heard of using XML to create a config
file.
> What would be the best format?
>
> Thank you.
>
>


Relevant Pages

  • Re: WSE 3.0 settings
    ... I think WSE should apply settings on fly. ... should look for the settings in the calling assembly config file (Calling ... I want to use third party DLL (Or I have to develop a DLL to be used in ...
    (microsoft.public.dotnet.framework.webservices.enhancements)
  • Re: ConfigParser.items sorting
    ... The thing is that I wanted to have the relay settings in the first ... these have a few input parameters and an output for clearing time. ... user will select the config file for the relay they want and therefore ...
    (comp.lang.python)
  • Re: appsetting in class doesnt work
    ... In 2003 I could easily change the config file settings from inside the app, ... Dim cnfg As System.Configuration.Configuration ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Attach and Access config file for Class Library
    ... The way this is *supposed* to work, the app.config would hold the settings ... including the settings for the dll. ... I don't use the config file API. ... and have your app simply load the xml file from the ...
    (microsoft.public.dotnet.framework)
  • re: Dynamic Documentation of Web.Config
    ... I need to document the web.config settings of all the asp.net apps that my company builds/maintains. ... The results will write to the page and link each key/value tag to its corresponding MSDN documentation ... will accessing a web config file with either a streamReader object or xmlReader object to read the file's contents effect the performance or stability of a web app? ... Scenario: I need to document the web.config settings of all the asp.net apps that my company builds/maintains and I would like to code a solution that presents the settings of each app dynamically. ...
    (microsoft.public.dotnet.framework.aspnet.buildingcontrols)