Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / CLR / September 2003

Tip: Looking for answers? Try searching our database.

Writing in .config XML application configuration file.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
msnews.microsoft.com - 09 Sep 2003 01:33 GMT
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
Herfried K. Wagner [MVP] - 09 Sep 2003 01:47 GMT
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
[quoted text clipped - 3 lines]
> 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

Signature

Herfried K. Wagner
MVP ? VB Classic, VB.NET
http://www.mvps.org/dotnet

Tom Dacon - 09 Sep 2003 01:47 GMT
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

> Hi all,
>
[quoted text clipped - 8 lines]
>
> Ivan Ivanov
Christoph Schittko [MVP] - 09 Sep 2003 02:20 GMT
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].

Signature

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

[0] http://www.microsoft.com/winlogo/software/tech_req.mspx
[1]
http://www.gotdotnet.com/Community/Workspaces/Workspace.aspx?id=01875f69-9358-43
7b-a8ae-fa4bf2e3080f

> Hi all,
>
[quoted text clipped - 8 lines]
>
> Ivan Ivanov
msnews.microsoft.com - 09 Sep 2003 17:18 GMT
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

> 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].

http://www.gotdotnet.com/Community/Workspaces/Workspace.aspx?id=01875f69-9358-43
7b-a8ae-fa4bf2e3080f

> > Hi all,
> >
[quoted text clipped - 9 lines]
> >
> > Ivan Ivanov
Christoph Nahr - 09 Sep 2003 19:48 GMT
>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.
Signature

http://www.kynosarges.de


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.