473,385 Members | 1,602 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,385 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 11 '05 #1
6 4734
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
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
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
>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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: kathy | last post by:
What Application Configuration File is? And when/where/how to use it? Any documents on that? MSDN has somrthings scatter everywhere - hard to follow. thanks,
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...
1
by: mqsash | last post by:
Hi, How do I use a configuration file with <codebase> to deploy a C# assembly as a cab file (in an html) ? The config file has the <codebase> element which points to the proper cab file. The...
1
by: TT (Tom Tempelaere) | last post by:
Hi people We have a strange (unexpected) problem with our application configuration file. When we place the config file in the same directory as the assembly it is deleted when we build our...
3
by: A.M | last post by:
Hi, We know that Console.exe looks for Console.exe.config as application configuration file. Can I define/change the application configuration file inside that actual application code? ...
3
by: FireStarter | last post by:
I know how to read from an application configuration file, by using System.Configuration.AppSettingsReader. This object does not allow writing a value back though. Does anybody know how to do...
12
by: Charles Law | last post by:
A client has just reported that when they run a VB.NET application on Windows 2000 an error is reported "Cannot find Application Configuration File". It runs fine on Windows XP Pro. Does anyone...
3
by: Barry Erick | last post by:
I guess the express edition does not have this configuration file. I had been using a ini file with getPrivateProfileString, but have not found an example that works in VB 2005 ee , so I looked for...
0
JOHNYKUTTY
by: JOHNYKUTTY | last post by:
Hey, I am developing an application in C#.net, i want to store some settings in application configuration file. iused the followin code ConfigurationSettings.AppSettings.Set("folder",...
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...
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.