.NET ini equivalent

G

guy

I've come across a general XML file that can be used for reading application
specific parameters to store from one running to another (for example last
screen position) but can't remember where I found it. Can someone please
remind me what the XML file is called and the class/namespace used to
manipulate it? It's the .NET replacement for using INI files.

Also is this the standard way to store information such as last used
directory for certain tasks etc. or what is the standard? Registry?

Thanks
 
B

Bruno Jouhier [MVP]

It is the file called MyApplication.exe.config.

To create it with Visual Studio, you can do "Add Item..." to your project
and choose "Configuration file". This will create a file called App.config.
When you compile your projet, the App.config file will be copied to
bin\Debug and renamed MyApplication.exe.config. The format of the file is
described in the online doc (search for configuration).

Bruno.
 
G

guy

That rang the bell and I remember using that file on a project some while
back. Can't you write from the app to that file? I thought you could.

Thanks guys
 
B

Bruno Jouhier [MVP]

No, you can only read settings from this file!

So you have to create your own setting file (and place it somewhere in the
Documents and settings\...\Application Data area rather than under Program
Files, to follow the MS guidelines). You can use XML serialization to
serialize your settings (easy and extensible).

Bruno.
 
G

Guest

Hi guy,

Adding on to what everybody said, the application will read the
configuration settings only during the initial load. You will not be able to
re-load the settings from app.config after the application has been loaded -
you will have to restart the application.

The ConfigurationSettings class allows you to only read the settings. No
direct facility is provided by the framework to write to it. But this won't
be much tough to implement.

The foto Vision sample @ windowsforms.net has a settings writer which writes
to the file. Maybe you could get the sample and go thru the code for doing
this. The link is:
http://www.windowsforms.net/Applications/application.aspx?PageID=50&tabindex=8

HTH,
Rakesh Rajan
 
G

guy

Thanks Rakesh,

So what is the standard for saving application settings when exiting an
application. For example if the user changes settings in the Tools ->
Options dialog and you want to restore the settings to the user's
preferences on next application startup. Is there a documented MS or other
standard that says where theses settings should be stored.

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top