473,385 Members | 1,325 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Writing value to config file

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
4 2933
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
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
> 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
> 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Paul C-T | last post by:
Hi, Am I trying to be too clever here? I am trying to write a PHP page to enable me to enter values into a form then write those values to a text file. I want to use the form & table that...
2
by: Job Lot | last post by:
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 ...
5
by: Robert Oschler | last post by:
I am converting a Perl script over to "C" for a potential open source project. I need some open source "C" code that will give me the same functionality of a Perl Style associative array: ...
2
by: MK | last post by:
Is there any way to write into the app config at runtime? I want to store position, height and width of my forms.
19
by: Noozer | last post by:
I need to keep my application settings in a file that users can copy/backup/etc. Before I start using the old INI file standard, is there any easy way to use XML files to hold application...
1
by: chauc3r | last post by:
I'm having problems writing to a text file. Basically it refuses to write anything. The file is created. At the appropiate times it goes into the correct if statements (I have verified this...
0
by: Rum | last post by:
Hi, I`m writing an application that can be updated from remote server. Application config file is updating too (adding new sections etc...) When application is updating i make a copy of old config...
6
by: Peted | last post by:
Hi, im wanting to store some custom text strings in the app.config file of a c# app, to be retreived and updated when the app runs. using c# 2005 express in my testing i am using the code...
0
parshupooja
by: parshupooja | last post by:
Hey All, I have old vb.net application and I have various users for that.where I have XML file as datasource. Till now for each user application was installed seperately. only difference...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.