473,329 Members | 1,315 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,329 software developers and data experts.

Writing in .config XML application configuration file.

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 20 '05 #1
5 6403
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 20 '05 #2
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 20 '05 #3
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 20 '05 #4
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 20 '05 #5
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 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: msnews.microsoft.com | last post by:
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...
16
by: DraguVaso | last post by:
Hi, I have a Windows Service running (made in VB.NET), and wanted to be able to change from time to time some parameters by changing them in the App.config. But it seems that the application...
16
by: Frank Oquendo | last post by:
ConfigurationSettings.AppSettings allows me to read from my config but how do I write to my config file? -- There are 10 kinds of people. Those who understand binary and those who don't. ...
4
by: tommy | last post by:
hello everbody, i write a little asp-application with forms-authentication. i copy my aspx-files with web.config to my webspace and i get the error above... i tried to set the...
2
by: Sam | last post by:
Inquiry? -------- I would like to authenticate all subdirectory via asp.net at Windows Server 2003 and IIS 6.0 but it prompt an error message as shown as below: Runtime Error? --------------...
1
by: Robert | last post by:
I have a server where the main web application (root) is now migrated to 2.0. It's web.config has a line where it adds the system.data.oracleclient in the configuration and assembiles section. ...
19
by: Noozer | last post by:
I need to keep my application settings in a file that users can copy/backup/etc. Before I start using the old INI file standard, is there any easy way to use XML files to hold application...
8
by: aabdis | last post by:
Hello All.... I have a question... i have two Windows apps (one UI, and one service) which use a common DLL that hands out database results and such to the two apps. The DLL always connects to...
3
by: Blasting Cap | last post by:
I am working on a web app that I want to be able to use a separate config file on, in addition to the web.config file that's already working in the application. If I put the following in the...
6
by: Peted | last post by:
Hi, im wanting to store some custom text strings in the app.config file of a c# app, to be retreived and updated when the app runs. using c# 2005 express in my testing i am using the code...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.