473,395 Members | 1,571 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Best format for configuration file?

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
7 11024
"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
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

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
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

"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
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
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Martin Smith | last post by:
If a class has no need for any specific clean up code in a particular catch block is there any benefit to catching and rethrowing exceptions, rather than just letting the original exception bubble up...
2
by: Luis Serrano | last post by:
Hi all, I'm trying to generate labels to print in several different formats, all of them with their own height,width and page margins. We've got this done in MS Access 2000, using a designed...
7
by: | last post by:
In the beginning we had Ini files. Later we had registery files. Now have xml files and our read-only myapp.config file. My question now, is what is the best way to store and load user and...
3
by: michael.lang | last post by:
I am using PostBuild events in a C# project to run some tasks, but only when in release configuration mode. The build events run perfectly as expected when run. The problem comes when I save the...
2
by: js | last post by:
I got this error when I moved my application to a new Windows 2003 server. I installed and recompiled the 'Microsoft.Practices.EnterpriseLibrary - June 2005" then added these assemblies to the...
2
by: Thirsty Traveler | last post by:
I have an application that will be accessing an array of ports obtained from a config file. What would be the best way to do populate the array if the config file has, say, the following format: ...
5
by: Allan Ebdrup | last post by:
I have a webservice in ASP.Net 2.0, I need to store and load a xml configuration file in relation to one of the web methods in my webservice. What's the best place to store and the best way to load...
1
by: Neo007 | last post by:
**File Conversion from CSV format to Excel(.xsl) C# Detailed Requirement is : Requirements for File Conversion Application: 1.My Application must be command-line it should indicate success...
0
by: =?Utf-8?B?QWxoYW1icmEgRWlkb3MgRGVzYXJyb2xsbw==?= | last post by:
Hi misters, I have an app.config (UTF-8 format file). I create an application winforms for changes and save configuration programatically. When I save changes the format file changes to ANSI ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.