Registry vs. ini-files

  • Thread starter Thread starter Bob Olsson
  • Start date Start date
B

Bob Olsson

Hello all!

I´m going to develop a windows smartclient and can´t find the information I
need. Where do I store user-settings like paths, background colour and so
on. I´ve read an article about the ups and downs of registry versus files
but i can´t find it now. Can someone please help me?

Thanks in advance!
/Bobby
 
in my opinion, the registry should only be used when the
nature of the application absolutely requires it.

COM applications are an excellent example of this need. A
COM application allows other applications to use its COM
control through its class ID (clsid). This ID is easily
placed in the registry by the COM server application, and
easily retrieved by a COM client. Without a central data
repository like the registry, writing COM apps would be
that much harder - perhaps even impossible.

more details you can find at
http://www.crtimmonsinc.com/Frontend/Desktop/DesktopDefault
..aspx?tabid=1015.

But the best way if you are using .NET is config files.
 
Bob said:
Hello all!

I´m going to develop a windows smartclient and can´t find the
information I need. Where do I store user-settings like paths,
background colour and so on. I´ve read an article about the ups and
downs of registry versus files but i can´t find it now. Can someone
please help me?

Thanks in advance!
/Bobby

Just to supplement the questions you have had so far. Microsoft is
discouraging developers from using the registry or INI files. The problem
with the registry is that it involves a separate 'registration' step (this
may be hidden: occuring when the app first starts), and the data resides in
a location other than the application directory. This means that if you move
the app to another machine the settings don't move with it. If you uninstall
the app, you have to remove the registry settings. INI files can be stored
in the app directory, but they are limited due to their format, XML is far
more flexible.

Config files are XML files in the app directory, so you can copy or delete
them. However, config files are read-only (the current version of the
framework does not have a class specifically to read them, although you can
use the XML classes). They should be treated in the same way as command line
switches, ie, the app does not write to the config file and even if it does,
the settings are not picked up by the app until it is restarted. (Contrast
that to the registry and INI files, where settings can be re-read).

Also, settings in the config file are per-app, they are not per-user as you
are requesting. One solution is to read/write an XML file in Isolated
Storage. On this page:
http://www.c-sharppro.com/features/2003/09/cs200309rg_f/cs200309rg_f.asp I
explain some code to do this. The downside of using isolated storage is that
the file is not stored in the app folder, so if you move the app or delete
it the isolated storage is not affected. (The location of the files used in
isolated storage is a little cryptic.)

Richard
 
Back
Top