By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,652 Members | 1,468 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,652 IT Pros & Developers. It's quick & easy.

Writing value to config file

P: n/a
I 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.AppSett ings.Set("LidbsdPath",
g_strLidbsdPath)

I am getting an error message saying "Collection is read-only"? How can I
fix this
Nov 22 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
You cannot that way. You would need to load the config file into an
XmlDocument object and make the change, then save it.

The config file will not be reloaded until the app is reloaded.

"Job Lot" <Jo****@discussions.microsoft.com> wrote in message
news:1B**********************************@microsof t.com...
I 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.AppSett ings.Set("LidbsdPath",
g_strLidbsdPath)

I am getting an error message saying "Collection is read-only"? How can I
fix this

Nov 22 '05 #2

P: n/a
You cannot that way. You would need to load the config file into an
XmlDocument object and make the change, then save it.

The config file will not be reloaded until the app is reloaded.

"Job Lot" <Jo****@discussions.microsoft.com> wrote in message
news:1B**********************************@microsof t.com...
I 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.AppSett ings.Set("LidbsdPath",
g_strLidbsdPath)

I am getting an error message saying "Collection is read-only"? How can I
fix this

Nov 22 '05 #3

P: n/a
> I 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.AppSett ings.Set("LidbsdPath",
g_strLidbsdPath)

I am getting an error message saying "Collection is read-only"? How can I
fix this

This config file is for start-up only so you can add start-up configuation
like serial number or prdefined settings without having to recompile the
project...

Unless you are a power user, or administrator user, modern applications that
are installed inder "C:\Program Files" normally have read-only acces. And
the same is true for Internet based executables and applications run form
CD-ROM. Meaning you normall should not be able to write to any file located
in the C:\Program Files" folder. And that happens to be the location of that
config file.
So the question is now, where do I write the configurations?
The registration database could do the trick but even better is at these 3
new locations Microsoft is pushing:
All happen to be in the "My documents" folders....

If you need to save the configuration on one computer, then go to another
and load it from there then you use:

m_RoamingUserConfig.ConfigurationType=Environment. SpecialFolder.ApplicationD
ata;

If you need the configuration the same for any user logged on that same
machine but independend of another machine then use:

m_AllUserConfig.ConfigurationType=Environment.Spec ialFolder.CommonApplicatio
nData;

And finally, and probably most needed, for user independend configuration
location:

m_LocalUserConfig.ConfigurationType=Environment.Sp ecialFolder.LocalApplicati
onData;

I hope this helps?

--
http://www.skyscan.be
Nov 22 '05 #4

P: n/a
> I 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.AppSett ings.Set("LidbsdPath",
g_strLidbsdPath)

I am getting an error message saying "Collection is read-only"? How can I
fix this

This config file is for start-up only so you can add start-up configuation
like serial number or prdefined settings without having to recompile the
project...

Unless you are a power user, or administrator user, modern applications that
are installed inder "C:\Program Files" normally have read-only acces. And
the same is true for Internet based executables and applications run form
CD-ROM. Meaning you normall should not be able to write to any file located
in the C:\Program Files" folder. And that happens to be the location of that
config file.
So the question is now, where do I write the configurations?
The registration database could do the trick but even better is at these 3
new locations Microsoft is pushing:
All happen to be in the "My documents" folders....

If you need to save the configuration on one computer, then go to another
and load it from there then you use:

m_RoamingUserConfig.ConfigurationType=Environment. SpecialFolder.ApplicationD
ata;

If you need the configuration the same for any user logged on that same
machine but independend of another machine then use:

m_AllUserConfig.ConfigurationType=Environment.Spec ialFolder.CommonApplicatio
nData;

And finally, and probably most needed, for user independend configuration
location:

m_LocalUserConfig.ConfigurationType=Environment.Sp ecialFolder.LocalApplicati
onData;

I hope this helps?

--
http://www.skyscan.be
Nov 22 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.