Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Writing value to config file

Status
Not open for further replies.

meinhunna

Programmer
Jul 31, 2004
118
AU
am trying to write value for a key in <appSettings><add key="LidbsdPath" value="" /></appSettings> section of config file from vb.net app, using statement below

System.Configuration.ConfigurationSettings.AppSettings.Set("LidbsdPath", g_strLidbsdPath)

I am getting an error message saying "Collection is read-only"? How can I fix this
 
If you can get past the arogant insulting nature of the author, he does make a valid point. (and a mildly moronic one about the write access in the program files folder).

Saving you application's config info in it's folder means that you can only have 1 set of settings. Even if you have 2+ users on the same machine (common in business settings, more common in schools, and an absolute in terminal systems like Cytrix).

Saving info to a config file in the user's Application Data folder will make it part of their roaming profile. That means that any number of people could log on to that machine and have their own settings, and that they could goto any other machine on the network (provided they have a Roaming Profile) and have the same settings.

so, use the 2 environment functions he mentions:
Code:
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
For user settings

Code:
Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData)
For common application settings for all users

-Rick

----------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top