[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.sdk

Writing in .config XML application configuration file.

msnews.microsoft.com

9/9/2003 12:33:00 AM

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


5 Answers

Herfried K. Wagner

9/9/2003 12:47:00 AM

0

Hello,

"msnews.microsoft.com" <ivan.ivanov@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/opti...

--
Herfried K. Wagner
MVP &#183; VB Classic, VB.NET
http://www.mvps....


Tom Dacon

9/9/2003 12:48:00 AM

0

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" <ivan.ivanov@tecan.com> wrote in message
news:%23hSkvnmdDHA.2816@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
>
>


Christoph Schittko

9/9/2003 1:20:00 AM

0

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/tec...
[1]
http://www.gotdotnet.com/Community/Workspaces/Workspace.aspx?id=01875f69-9358-437b-a8ae-fa...
"msnews.microsoft.com" <ivan.ivanov@tecan.com> wrote in message
news:#hSkvnmdDHA.2816@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
>
>


msnews.microsoft.com

9/9/2003 4:18:00 PM

0

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]" <christophdotnetINVALID@austin.rr.com> wrote in
message news:OZ2oCCndDHA.1204@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/tec...
> [1]
>
http://www.gotdotnet.com/Community/Workspaces/Workspace.aspx?id=01875f69-9358-437b-a8ae-fa...
> "msnews.microsoft.com" <ivan.ivanov@tecan.com> wrote in message
> news:#hSkvnmdDHA.2816@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
> >
> >
>
>


Christoph Nahr

9/9/2003 6:49:00 PM

0

On Tue, 9 Sep 2003 09:18:22 -0700, "msnews.microsoft.com"
<ivan.ivanov@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.kyn...