473,545 Members | 2,081 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Configur ation) like the
ConfigurationSe ttings.AppSetti ngs property, but I was not able to find
anything to write app settings in these files. Isn't this kind of
"asymmetric al"? Anyone familiar with the reasons of such a lack?

Thanks a lot,

Ivan Ivanov
Nov 11 '05 #1
6 4749
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.microso ft.com" <iv*********@te can.com> wrote in message
news:%2******** ********@TK2MSF TNGP10.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.Configur ation) like the
ConfigurationSe ttings.AppSetti ngs property, but I was not able to find
anything to write app settings in these files. Isn't this kind of
"asymmetric al"? Anyone familiar with the reasons of such a lack?

Thanks a lot,

Ivan Ivanov

Nov 11 '05 #2
Hello,

"msnews.microso ft.com" <iv*********@te can.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.Configur ation) like the ConfigurationSe ttings.
AppSettings property, but I was not able to find
anything to write app settings in these files. Isn't this kind of
"asymmetric al"? 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.microso ft.com" <iv*********@te can.com> wrote in message
news:#h******** ******@TK2MSFTN GP10.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.Configur ation) like the
ConfigurationSe ttings.AppSetti ngs property, but I was not able to find
anything to write app settings in these files. Isn't this kind of
"asymmetric al"? 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.Configur ation) like the
ConfigurationS ettings.AppSett ings 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)i nova.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
WritePrivetePro fileString or so.

Thanks,

Ivan

"Christoph Schittko [MVP]" <ch************ ********@austin .rr.com> wrote in
message news:OZ******** ******@TK2MSFTN GP11.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.microso ft.com" <iv*********@te can.com> wrote in message
news:#h******** ******@TK2MSFTN GP10.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.Configur ation) like the
ConfigurationSe ttings.AppSetti ngs property, but I was not able to find
anything to write app settings in these files. Isn't this kind of
"asymmetric al"? 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.microso ft.com"
<iv*********@te can.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
WritePrivetePr ofileString or so.


There are three classes devoted to simplifying registry access, by the
way. Check out the System.Microsof t.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
3439
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
577
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 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...
1
1973
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 html page and the cab file are in the same location. But upon invoking the html page nothing happens. Even the FusLogvw.exe does not register...
1
239
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 project. The name of the config file is "App.exe.config" with App the name of our application (the executable is App.exe) We tested the same thing in...
3
1253
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? Thanks, Alan
3
1570
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 this? The application is Windows Forms.
12
1884
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 know what file it could be referring to? The application does use bespoke files when it starts, but these are all present. TIA Charles
3
5072
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 the xml way and the example at microsoft is for the full and not express edition. It says to right-click on the project and select Add New then...
0
956
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", txtfolder.Text.Trim()); but it is not working properly. Anyone can help me??????? thank you
0
7468
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7656
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7423
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7757
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5329
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4945
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3450
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1884
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
704
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.