By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,732 Members | 831 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,732 IT Pros & Developers. It's quick & easy.

Writing in .config XML application configuration file.

P: n/a
Hi all,

I was trying to find an easy way to write in the standard configuration
(like app.config) xml-based files. I found classes that can be used to read
this information (in System.Configuration) like the
ConfigurationSettings.AppSettings property, but I was not able to find
anything to write app settings in these files. Isn't this kind of
"asymmetrical"? Anyone familiar with the reasons of such a lack?

Thanks a lot,

Ivan Ivanov
Nov 11 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
For personal settings, it appears that MS recommends that you maintain a
separate file to hold them. The official story for the app config file is
that it's intended to be read-only and to contain more or less invariant
application settings, independent of any user preferences. You can use a
separate XML file, for instance, to maintain user preferences. I'd suggest
that you consider keeping such a file in isolated storage (see the
IsolatedStorage class for details).

Tom Dacon
Dacon Software Consulting

"msnews.microsoft.com" <iv*********@tecan.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi all,

I was trying to find an easy way to write in the standard configuration
(like app.config) xml-based files. I found classes that can be used to read this information (in System.Configuration) like the
ConfigurationSettings.AppSettings property, but I was not able to find
anything to write app settings in these files. Isn't this kind of
"asymmetrical"? Anyone familiar with the reasons of such a lack?

Thanks a lot,

Ivan Ivanov

Nov 11 '05 #2

P: n/a
Hello,

"msnews.microsoft.com" <iv*********@tecan.com> schrieb:
I was trying to find an easy way to write in the standard
configuration (like app.config) xml-based files. I found
classes that can be used to read this information
(in System.Configuration) like the ConfigurationSettings.
AppSettings property, but I was not able to find
anything to write app settings in these files. Isn't this kind of
"asymmetrical"? Anyone familiar with the reasons of such a lack?


config files should not be modified by the application, that's why there
are no methods available for modifying them. Nevertheless, you can use
the XML classes provided by the framework to make changes to the config
files.

The config file should not be used to save user preferences. You can
use something like this instead:

http://www.palmbytes.de/content/dotnet/optionslib.htm

--
Herfried K. Wagner
MVP VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 11 '05 #3

P: n/a
I agree with all of the above. You can find the reasons why app.config files
are not writable in the the Windows Logo Requirements [0]. However, you can
still leverage the same programming model for user specific settings if you
intergrate Microsoft's Confiuration Management Application Block [1].

--
HTH
Christoph Schittko [MVP]
Software Architect, .NET Mentor

[0] http://www.microsoft.com/winlogo/software/tech_req.mspx
[1]
http://www.gotdotnet.com/Community/W...e-fa4bf2e3080f
"msnews.microsoft.com" <iv*********@tecan.com> wrote in message
news:#h**************@TK2MSFTNGP10.phx.gbl...
Hi all,

I was trying to find an easy way to write in the standard configuration
(like app.config) xml-based files. I found classes that can be used to read this information (in System.Configuration) like the
ConfigurationSettings.AppSettings property, but I was not able to find
anything to write app settings in these files. Isn't this kind of
"asymmetrical"? Anyone familiar with the reasons of such a lack?

Thanks a lot,

Ivan Ivanov

Nov 11 '05 #4

P: n/a
>I was trying to find an easy way to write in the standard configuration
(like app.config) xml-based files. I found classes that can be used to read
this information (in System.Configuration) like the
ConfigurationSettings.AppSettings property, but I was not able to find
anything to write app settings in these files. Isn't this kind of
"asymmetrical"? Anyone familiar with the reasons of such a lack?


Consider this - in a well managed environment, your apps would
typically reside in the c:\program files area - by default, normal
users do not have permissions to write there. So even if you could
write back settings to the app's config file in the .NET classes, most
likely that would fail for your users since they can't write anything
to the directory where the app resides.

If you need to store user settings, store them into a user directory
or the Isolated Storage area. There are lots of freeware classes out
there that allow you to store user settings in XML or binary format.

Marc
================================================== ==============
Marc Scheuner May The Source Be With You!
Bern, Switzerland m.scheuner(at)inova.ch
Nov 11 '05 #5

P: n/a
Thanks a lot for the input.

I did not mean that I want to necessarily write in the app.config file. I
was looking for .net support for writing user settings in any kind of .ini -
like file (or registry settings for that matter, even though MS does not
recommend using the registry now!). I know that I can use XMLReaders and
such but I was looking for a 1 - line solution like good old
WritePriveteProfileString or so.

Thanks,

Ivan

"Christoph Schittko [MVP]" <ch********************@austin.rr.com> wrote in
message news:OZ**************@TK2MSFTNGP11.phx.gbl...
I agree with all of the above. You can find the reasons why app.config files are not writable in the the Windows Logo Requirements [0]. However, you can still leverage the same programming model for user specific settings if you intergrate Microsoft's Confiuration Management Application Block [1].

--
HTH
Christoph Schittko [MVP]
Software Architect, .NET Mentor

[0] http://www.microsoft.com/winlogo/software/tech_req.mspx
[1]
http://www.gotdotnet.com/Community/W...e-fa4bf2e3080f "msnews.microsoft.com" <iv*********@tecan.com> wrote in message
news:#h**************@TK2MSFTNGP10.phx.gbl...
Hi all,

I was trying to find an easy way to write in the standard configuration
(like app.config) xml-based files. I found classes that can be used to

read
this information (in System.Configuration) like the
ConfigurationSettings.AppSettings property, but I was not able to find
anything to write app settings in these files. Isn't this kind of
"asymmetrical"? Anyone familiar with the reasons of such a lack?

Thanks a lot,

Ivan Ivanov


Nov 11 '05 #6

P: n/a
On Tue, 9 Sep 2003 09:18:22 -0700, "msnews.microsoft.com"
<iv*********@tecan.com> wrote:
I did not mean that I want to necessarily write in the app.config file. I
was looking for .net support for writing user settings in any kind of .ini -
like file (or registry settings for that matter, even though MS does not
recommend using the registry now!). I know that I can use XMLReaders and
such but I was looking for a 1 - line solution like good old
WritePriveteProfileString or so.


There are three classes devoted to simplifying registry access, by the
way. Check out the System.Microsoft.Win32 namespace.
--
http://www.kynosarges.de
Nov 11 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.