Replacement for INI Files? 
Author Message
 Replacement for INI Files?

I am trying to think through what I should use as a logical
replacement for ini files since they have been obsolete for a while
now.
I use them to maintain data such as high scores and small lists of
files for my apps, I don't use the registry since my PC is a
substitute for the electric train set I never had and so I tend to
play about with the hardware and re-install the OS (W2K Pro) quite
frequently. In any event it seems to me that using the registry
contradicts the philosophy behind .net of machine/OS independence,
only Windows has a registry.
I have looked at the Resource Reader/Writer as one possibility,
although so far I haven't been able to insert or extract individual
items, perhaps that's not what it is intended for?
The other option would be to use an XML file and to incorporate
read/write capability in my apps.
Does anybody have any thought/recommendations on this?
Is there anything else I could use?
Currently I still use INI files via the API but having moved to C# and
.net I want to bring my thinking up to date.

Many thanks.
--
Jeff Gaines Damerham Hampshire UK



Mon, 28 Mar 2005 18:03:41 GMT  
 Replacement for INI Files?
IMO I have superceeded my inifile programatic data to xml file structures.
any app config that is needed to configure the app I used the app.config
facility within .Net.

Hope this helps, and p.s this comes with the disclaimer that I am not a
guru, and probably is not the best way to do it :)


Quote:

> I am trying to think through what I should use as a logical
> replacement for ini files since they have been obsolete for a while
> now.
> I use them to maintain data such as high scores and small lists of
> files for my apps, I don't use the registry since my PC is a
> substitute for the electric train set I never had and so I tend to
> play about with the hardware and re-install the OS (W2K Pro) quite
> frequently. In any event it seems to me that using the registry
> contradicts the philosophy behind .net of machine/OS independence,
> only Windows has a registry.
> I have looked at the Resource Reader/Writer as one possibility,
> although so far I haven't been able to insert or extract individual
> items, perhaps that's not what it is intended for?
> The other option would be to use an XML file and to incorporate
> read/write capability in my apps.
> Does anybody have any thought/recommendations on this?
> Is there anything else I could use?
> Currently I still use INI files via the API but having moved to C# and
> .net I want to bring my thinking up to date.

> Many thanks.
> --
> Jeff Gaines Damerham Hampshire UK




Mon, 28 Mar 2005 18:08:02 GMT  
 Replacement for INI Files?
p.s instead of resorce reader/writer, use resourcemanager as below..
inplement a resx file into your app and hey presto, you can get specific
values out.

ResourceManager resource = new ResourceManager("Your default namespace goes
here", Assembly.GetExecutingAssembly());

string s = resource.GetString("The value of the NAME couln in your resource
file));


Quote:
> IMO I have superceeded my inifile programatic data to xml file structures.
> any app config that is needed to configure the app I used the app.config
> facility within .Net.

> Hope this helps, and p.s this comes with the disclaimer that I am not a
> guru, and probably is not the best way to do it :)



> > I am trying to think through what I should use as a logical
> > replacement for ini files since they have been obsolete for a while
> > now.
> > I use them to maintain data such as high scores and small lists of
> > files for my apps, I don't use the registry since my PC is a
> > substitute for the electric train set I never had and so I tend to
> > play about with the hardware and re-install the OS (W2K Pro) quite
> > frequently. In any event it seems to me that using the registry
> > contradicts the philosophy behind .net of machine/OS independence,
> > only Windows has a registry.
> > I have looked at the Resource Reader/Writer as one possibility,
> > although so far I haven't been able to insert or extract individual
> > items, perhaps that's not what it is intended for?
> > The other option would be to use an XML file and to incorporate
> > read/write capability in my apps.
> > Does anybody have any thought/recommendations on this?
> > Is there anything else I could use?
> > Currently I still use INI files via the API but having moved to C# and
> > .net I want to bring my thinking up to date.

> > Many thanks.
> > --
> > Jeff Gaines Damerham Hampshire UK




Mon, 28 Mar 2005 18:13:20 GMT  
 Replacement for INI Files?

Quote:
> I am trying to think through what I should use as a logical
> replacement for ini files since they have been obsolete for a while
> now.

I also stopped to use INI files. What's more - I've found app.config file
not quite convenient.
Instead, I have a public class called CMyOptions with public variables to
hold any needed configuration parameters (a lot of data of type string, a
lot of ints, doubles etc.)

Instead of writing and reading an INi file I use XMLSerialization to read
and write one public static variable of type CMyOptions. this variable is
then used in the code to read and store the configuration.

because XMLSerialization and deserialization is really simple ( both take 4
lines of code, read docs for further info ) you don't have to play with any
XML reading/parsing.

for example (serialization):

   XmlSerializer serializer = new XmlSerializer(typeof(CMyOptions));
   TextWriter tw = new StreamWriter("options.myini");
   serializer.Serialize(tw, myOptionsInstance);
   tw.Close();

deserialization:

   XmlSerializer serializer = new XmlSerializer(typeof(CMyOptions));
   TextReader tr = new StreamReader("options.myini");
   CMyOptions myOptionsInstance = (CMyOptions)serializer.Deserialize(tr);
   tr.Close();

Viola. This is great, because XMLSerialization stores objects as xml. so you
can edit your configuration manually.

Regards, Wiktor Zychla



Mon, 28 Mar 2005 19:03:28 GMT  
 Replacement for INI Files?
On Thu, 10 Oct 2002 13:03:28 +0200, "Wiktor Zychla"

Quote:

>> I am trying to think through what I should use as a logical
>> replacement for ini files since they have been obsolete for a while
>> now.

>I also stopped to use INI files. What's more - I've found app.config file
>not quite convenient.
>Instead, I have a public class called CMyOptions with public variables to
>hold any needed configuration parameters (a lot of data of type string, a
>lot of ints, doubles etc.)

>Instead of writing and reading an INi file I use XMLSerialization to read
>and write one public static variable of type CMyOptions. this variable is
>then used in the code to read and store the configuration.

>because XMLSerialization and deserialization is really simple ( both take 4
>lines of code, read docs for further info ) you don't have to play with any
>XML reading/parsing.

>for example (serialization):

>   XmlSerializer serializer = new XmlSerializer(typeof(CMyOptions));
>   TextWriter tw = new StreamWriter("options.myini");
>   serializer.Serialize(tw, myOptionsInstance);
>   tw.Close();

>deserialization:

>   XmlSerializer serializer = new XmlSerializer(typeof(CMyOptions));
>   TextReader tr = new StreamReader("options.myini");
>   CMyOptions myOptionsInstance = (CMyOptions)serializer.Deserialize(tr);
>   tr.Close();

>Viola. This is great, because XMLSerialization stores objects as xml. so you
>can edit your configuration manually.

>Regards, Wiktor Zychla

Wiktor / Martin

Many thanks for your replies.

I have tried a small test app and it works fine, look like it had
better be XML in future!

I am not sure I would want to convert a 25MB database to XML though,
it seems to me that one small slip in the XML document and your
database has gone west!

--
Jeff Gaines Damerham Hampshire UK



Mon, 28 Mar 2005 20:44:53 GMT  
 Replacement for INI Files?
Hi Wiktor,

Can you please elaborate why you haven't found app.config as convenient? We
been thinking of using it in our app. . May be we can benifit from your
experience.

Regards
Mrinal


Quote:
> On Thu, 10 Oct 2002 13:03:28 +0200, "Wiktor Zychla"

> >> I am trying to think through what I should use as a logical
> >> replacement for ini files since they have been obsolete for a while
> >> now.

> >I also stopped to use INI files. What's more - I've found app.config file
> >not quite convenient.
> >Instead, I have a public class called CMyOptions with public variables to
> >hold any needed configuration parameters (a lot of data of type string, a
> >lot of ints, doubles etc.)

> >Instead of writing and reading an INi file I use XMLSerialization to read
> >and write one public static variable of type CMyOptions. this variable is
> >then used in the code to read and store the configuration.

> >because XMLSerialization and deserialization is really simple ( both take
4
> >lines of code, read docs for further info ) you don't have to play with
any
> >XML reading/parsing.

> >for example (serialization):

> >   XmlSerializer serializer = new XmlSerializer(typeof(CMyOptions));
> >   TextWriter tw = new StreamWriter("options.myini");
> >   serializer.Serialize(tw, myOptionsInstance);
> >   tw.Close();

> >deserialization:

> >   XmlSerializer serializer = new XmlSerializer(typeof(CMyOptions));
> >   TextReader tr = new StreamReader("options.myini");
> >   CMyOptions myOptionsInstance = (CMyOptions)serializer.Deserialize(tr);
> >   tr.Close();

> >Viola. This is great, because XMLSerialization stores objects as xml. so
you
> >can edit your configuration manually.

> >Regards, Wiktor Zychla

> Wiktor / Martin

> Many thanks for your replies.

> I have tried a small test app and it works fine, look like it had
> better be XML in future!

> I am not sure I would want to convert a 25MB database to XML though,
> it seems to me that one small slip in the XML document and your
> database has gone west!

> --
> Jeff Gaines Damerham Hampshire UK




Mon, 28 Mar 2005 21:45:33 GMT  
 Replacement for INI Files?

Quote:
> Can you please elaborate why you haven't found app.config as convenient?
We
> been thinking of using it in our app. . May be we can benifit from your
> experience.

first reason: with app.config you have to manually write an XML file with
proper configuration to be able to change it, with XML serialization of your
own object, you do not have to write anything - after first serialization, a
proper XML configuration file is created.

the second reason: having a class allows to get the configuration setting
easily ( I just use cMyConfigInstance.myProperty ). I do not have to ask
Configuration.AppSettings.Get(...)

third: having a class allows to deal with a lot of dynamic configurations.
just create an array of CMyOptions and you can change configurations in the
runtime. more - with explicit serialization you can specify a configuration
file name.

That's why I prefer to use XML serialization rather than app.config. Maybe
there's something that I miss.

Regards



Mon, 28 Mar 2005 22:25:06 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. 2nd try: need a C library file for reading Windows-style .INI files

2. please help newbie string replacement in big file

3. Please help with c string replacement on a big file

4. String replacement in source file

5. Maintaining .INI Files

6. Q:DotNETs version on INI files

7. Function to read a .ini file

8. How to read INI files (16bit DOS)

9. ini file class

10. Need source to read INI files, help?

11. Looking for source to read/write INI files?

12. C program for reading .ini files

 

 
Powered by phpBB® Forum Software