|
-
Mar 20th, 2006, 12:21 PM
#1
Thread Starter
Addicted Member
VB2005 App.config
Hello,
Does anyone have a code example on how to read/write to the app.config file within an application? Here is a sample from my file:
<configuration>
<appSettings>
<add key="Authentication" value="Windows"/>
How would I read that value? It's NOT the same way you would do it in 2003. I tried but when I tried using
configuration.configurationsettings.getconfig("Authentication"), I get the message that "This method is obsolete, use system.configuration.configurationmanager.getsection instead."
But that method does not work either. Any ideas?
-
Mar 20th, 2006, 12:27 PM
#2
Addicted Member
Using Framework 1.1, VB.Net 2003 unless I
state otherwise 
-
Mar 20th, 2006, 12:32 PM
#3
Thread Starter
Addicted Member
Re: VB2005 App.config
Getting a message "Configuration Manager is not a member of Configuration". So this is still not working. I referenced the system.configuration DLL file to the project and still nothing. Any other suggestions?
Last edited by rjdpa; Mar 20th, 2006 at 12:43 PM.
-
Mar 20th, 2006, 07:02 PM
#4
Re: VB2005 App.config
You should probably be using application settings instead. Go to the Settings tab of the application properties and create a new setting named "Authentication". Make it type String and set the value to "Windows". Now at run time you just get it via My.Settings.Authentication. That's it. You can still use the old way if you like but it is much more tedious. Using settings allows you to easily change the value at run time as well if you want to.
-
Mar 21st, 2006, 02:38 PM
#5
Thread Starter
Addicted Member
Re: VB2005 App.config
I'm not able to figure out how to write the values into the settings. I will keep trying on the app.config... If anyone has any suggestions, please let me know.
-
Mar 21st, 2006, 05:41 PM
#6
Re: VB2005 App.config
I've done a bit more reading on application settings and it appears that if you set the scope of a setting to Application then it becomes ReadOnly as far as My.Settings is concerned. If you set the scope as User then you can change the values and save them using My.Settings.Save() but it will save the settings for the current user and not for all users.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|