Configuration Settings

  • Thread starter Thread starter Trey
  • Start date Start date
T

Trey

I can't believe that Dot.Net has no easy to use INI file replacement.

In Delphi you set up a class to read/write data from by using this
statement.

theINI := TIniFile.Create(filename);

To read from it you do something like:

frmMain.top := theINI.ReadInteger('INIT','Top',50);
frmMain.left := theINI.ReadInteger('INIT','Left',50);

and to write:

theINI.WriteInteger('INIT','Top',frmMain.Top);
theINI.WriteInteger('INIT','Left',frmMain.Left);

Pretty simple huh?

Am I missing something?
 
Yes, you are missing something! :) Try
System.Xml.XmlSerializer, you don't even have to manually
read the data yourself. You can create a config class
with the data you need to store as public variables or
public properties. Then simply call .Serialize and it'll
save all your data to an XML file of your choice. That's
it! Want to deserialize? Call .Deserialize, passing the
XML file, it'll create an instance of your config class
with all the data that was in the XML file. It's that
simple.
 
Trey,
Just wanted to suggest yet another method of managing your configuration settings. I have written an article that details this as an extension to the Configuration Settings class in .NET. This will store all of your information in an XML file. Check it out at:

<a href="http://www.codeproject.com/csharp/config_settings.asp" target="_blank">An extension for a Configuration Settings class in .NET</a>

Hope this helps,
Nick Parker
 
Back
Top