By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,467 Members | 1,500 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,467 IT Pros & Developers. It's quick & easy.

Best format for configuration file?

P: n/a
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.
Nov 15 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
"Jimbo" <None> wrote in message
news:Oh****************@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?

Hi Jimbo,

I recommend XML. Look for configuration file information in the docs. In
VS.NET, you can add a file named "app.config" to your application and work
with it in the IDE. When you compile, this file will be copied to your
output directory, where your dll is, and be renamed to <put your application
name here>.exe.config.

Joe
--
http://www.csharp-station.com
Nov 15 '05 #2

P: n/a
A .NET app can have a config file with the extension ".config". Suppose
your app is named "myapp.exe", then your config file must be named
"myapp.exe.config".

A simple config file looks like this:

<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="name1" value="value1" />
<add key="name2" value="value2" />
</appSettings>
</configuration>

Use System.Configuration.ConfigurationSettings to manipulate it.

Jimbo wrote:
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.


Nov 15 '05 #3

P: n/a

Hello Jimbo!
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?


The XML is good format for configuration files (IMO). And the XML
Serialization process is very simple to save and read XML files into objects
tree.

--
Roman S. Golubin
ICQ UIN 63253392
go*****************@arhcity.ru
Nov 15 '05 #4

P: n/a
Jimbo wrote:
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?


I'll risk being ridiculed, but INI files work perfect for me. The thing
about XML is that if you edit by hand you can corrupt really easily,
specially if someone unfamiliar with XML does it.

INI files are soooo straightforward and simple that it's much harder to
screw them up.

--
gabriel
Nov 15 '05 #5

P: n/a

"gabriel" <no@no--spam.com> wrote in message
news:33**************************@msgid.meganewsse rvers.com...
Jimbo wrote:
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?


I'll risk being ridiculed, but INI files work perfect for me. The thing
about XML is that if you edit by hand you can corrupt really easily,
specially if someone unfamiliar with XML does it.

INI files are soooo straightforward and simple that it's much harder to
screw them up.

--
gabriel


No ridicule from this end. Actually, ascii based ini files fit very well
into the .NET xcopy deployment scheme. Having your users become human xml
parsers is no fun.

bob
Nov 15 '05 #6

P: n/a
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.*********************@no-sp-am-eh-mail.com
remove all "no-sp-am-eh"s to reply

"Jimbo" <None> wrote in message
news:Oh****************@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.


Nov 15 '05 #7

P: n/a
"Jimbo" <None> wrote:
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.


For an example of managing a custom XML application configuration file look under

Working with Custom Application Files in C#

on

Visual C# .NET Code Samples
http://www.microsoft.com/downloads/d...displaylang=en
Nov 15 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.