PC Review


Reply
Thread Tools Rate Thread

Can app.config be updated by the user?

 
 
Dean Slindee
Guest
Posts: n/a
 
      22nd Aug 2004
I store several application settings in the project's "app.config" file. I
also have a form that reads these values and displays them in a listview so
that the user can adjust them. My question is: can the changes made by the
user to the settings values be saved back to "app.config" so that when the
application is launched tomorrow, the updated values are used?

Since the original app.config settings are loaded to
"projectName.exe.config", and updated there by the user, another way of
asking the same question is: how to write the values in
"projectName.exe.config" back to "app.config"?

Thanks,
Dean Slindee


 
Reply With Quote
 
 
 
 
Lucas Tam
Guest
Posts: n/a
 
      22nd Aug 2004
"Dean Slindee" <(E-Mail Removed)> wrote in
news:(E-Mail Removed):

> My question is: can the changes made by the
> user to the settings values be saved back to "app.config" so that when
> the application is launched tomorrow, the updated values are used?


No, the config files are read only, You'll need to write your own XML
classes to update the configs.

--
Lucas Tam ((E-Mail Removed))
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
 
Reply With Quote
 
Tom Dacon
Guest
Posts: n/a
 
      22nd Aug 2004
Microsoft 'prefers' that the app.config file be considered a read-only
application initialization repository. For one thing, since there's only one
file for the application it's machine-wide rather than user-specific. Thus
it's not a good place for user-specific preferences. Probably the best place
to store user preferences is in your own XML files, either in user-specific
isolated storage, or in the directory represented by
Application.UserAppDataPath.

Quite a few people, by now, have created libraries for managing user
preferences in XML files (I've certainly done it for my own personal use).
It's a shame that MS didn't supply wrapper classes for this in the
framework, since we're all having to re-invent the wheel on this. If you
look around places like www.gotdotnet.com or www.sourceforge.net you'll
undoubtedly come across one or more solutions to this problem that have been
contributed by that community. I haven't contributed my own, since I doubt
that the world needs another one.

Tom Dacon
Dacon Software Consulting

"Dean Slindee" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I store several application settings in the project's "app.config" file.

I
> also have a form that reads these values and displays them in a listview

so
> that the user can adjust them. My question is: can the changes made by

the
> user to the settings values be saved back to "app.config" so that when the
> application is launched tomorrow, the updated values are used?
>
> Since the original app.config settings are loaded to
> "projectName.exe.config", and updated there by the user, another way of
> asking the same question is: how to write the values in
> "projectName.exe.config" back to "app.config"?
>
> Thanks,
> Dean Slindee
>
>



 
Reply With Quote
 
Tom Dacon
Guest
Posts: n/a
 
      23rd Aug 2004
I should also add, as a disadvantage of trying to write into the app.config
file, that you can't guarantee that the user of the application will have
write permissions on the directory in which the application executable and
the config file reside. A system administrator might lock that directory
down, causing your application to fail with a permissions exception when you
tried to write to the file.

Tom Dacon

"Tom Dacon" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Microsoft 'prefers' that the app.config file be considered a read-only
> application initialization repository. For one thing, since there's only

one
> file for the application it's machine-wide rather than user-specific. Thus
> it's not a good place for user-specific preferences. Probably the best

place
> to store user preferences is in your own XML files, either in

user-specific
> isolated storage, or in the directory represented by
> Application.UserAppDataPath.
>
> Quite a few people, by now, have created libraries for managing user
> preferences in XML files (I've certainly done it for my own personal use).
> It's a shame that MS didn't supply wrapper classes for this in the
> framework, since we're all having to re-invent the wheel on this. If you
> look around places like www.gotdotnet.com or www.sourceforge.net you'll
> undoubtedly come across one or more solutions to this problem that have

been
> contributed by that community. I haven't contributed my own, since I doubt
> that the world needs another one.
>
> Tom Dacon
> Dacon Software Consulting
>
> "Dean Slindee" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > I store several application settings in the project's "app.config" file.

> I
> > also have a form that reads these values and displays them in a listview

> so
> > that the user can adjust them. My question is: can the changes made by

> the
> > user to the settings values be saved back to "app.config" so that when

the
> > application is launched tomorrow, the updated values are used?
> >
> > Since the original app.config settings are loaded to
> > "projectName.exe.config", and updated there by the user, another way of
> > asking the same question is: how to write the values in
> > "projectName.exe.config" back to "app.config"?
> >
> > Thanks,
> > Dean Slindee
> >
> >

>
>



 
Reply With Quote
 
scorpion53061
Guest
Posts: n/a
 
      23rd Aug 2004
TO write settings via an xml file:

http://www.kjmsolutions.com/xmlsettings.htm

To write settings to an app.config file....(not recommended)

http://www.kjmsolutions.com/download...onfigstuff.ZIP

to use Isolated storage..(must have adequate .NET permissions..)

http://www.kjmsolutions.com/download...igsystemio.ZIP

________________________________

From: Dean Slindee [private.php?do=newpm&u=]
Sent: Saturday, August 21, 2004 11:20 PM
To: microsoft.public.dotnet.languages.vb
Subject: Can app.config be updated by the user?



I store several application settings in the project's "app.config" file.
I
also have a form that reads these values and displays them in a listview
so
that the user can adjust them. My question is: can the changes made by
the
user to the settings values be saved back to "app.config" so that when
the
application is launched tomorrow, the updated values are used?

Since the original app.config settings are loaded to
"projectName.exe.config", and updated there by the user, another way of
asking the same question is: how to write the values in
"projectName.exe.config" back to "app.config"?

Thanks,
Dean Slindee


 
Reply With Quote
 
Éric Moreau [VB MVP]
Guest
Posts: n/a
 
      23rd Aug 2004
No but see this other app settings class:
http://www.west-wind.com/presentatio...ationclass.asp

--

HTH

Éric Moreau, MCSD, Visual Developer - Visual Basic MVP
Conseiller Principal / Senior Consultant
Concept S2i inc.(www.s2i.com)


"Dean Slindee" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I store several application settings in the project's "app.config" file.

I
> also have a form that reads these values and displays them in a listview

so
> that the user can adjust them. My question is: can the changes made by

the
> user to the settings values be saved back to "app.config" so that when the
> application is launched tomorrow, the updated values are used?
>
> Since the original app.config settings are loaded to
> "projectName.exe.config", and updated there by the user, another way of
> asking the same question is: how to write the values in
> "projectName.exe.config" back to "app.config"?
>
> Thanks,
> Dean Slindee
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Why does web.config get updated? Frank Rizzo Microsoft ASP .NET 1 12th Feb 2008 11:01 AM
trouble writing new and updated values to app.config file Peted Microsoft C# .NET 6 24th Aug 2007 11:55 AM
app.config and user.config files Mark Microsoft Dot NET Framework 9 12th Feb 2007 03:25 PM
User Config and Computer Config Sean B Microsoft Windows 2000 Group Policy 2 6th Aug 2004 05:49 PM
Empty Response using HttpWebRequest.GetResponse() after client's web.config updated Martin Microsoft Dot NET Framework 0 4th Dec 2003 10:29 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:26 PM.