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 / .NET SDK / December 2004

Tip: Looking for answers? Try searching our database.

modify application configuration file at runtime

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Leo - 07 Dec 2004 11:47 GMT
Dear All
I want to modify application configuration file at runtime. How to do this.
Please help in this.
Thanks
Signature

Leo

John M Deal - 07 Dec 2004 14:00 GMT
This is usually considered to be a bad practice.  Application
configuration files should only contain values that are "configure
once".  The reasons for this vary depending on the environment you work
in. For example in Windows forms applications a least privileged user
(i.e. a non-admin/non-power user) does not have the ability to write to
application director. In ASP.Net applications you run into the problem
that when the configuration file is written to the website resets itself
(effectively crashing whatever was being worked on by the users of the
site at that point in time).

A better option is to create your own custom configuration file to
contain application settings that you want to update on the fly.  You
can then put a file watch on this custom settings file so that your
application will know to reload the settings if it ever changes. From
there you can simply use whatever means you want to read and write the
file (i.e. XmlReader/Writer, Ini Interop, StreamReader/Writer...).  Just
be sure to test with an account that represents the same security rights
and privileges that the user of the application (or the host process)
will be using or you will likely get a shock when you deploy to your
production environment.

If you are creating a Windows forms application be sure to check into
using Isolated Storage and or the Application Data or User Data folders.
 You can find information on all three of these in the help files (they
are simply locations that Windows provides to help make sure the user
has the correct privileges to write files to).  Hope this helps.

Have A Better One!

John M Deal, MCP
Necessity Software

> Dear All
> I want to modify application configuration file at runtime. How to do this.
> Please help in this.
> Thanks

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.