C# access settings values
I need to change the location of where a database file is located in a C#.net 2008 desktop application, but I am having problems. When stepping through the code, I find that I need to change a 'settings.settings' file. Bascially I need to be able to access the properties in some kind of a designer and I have not be able to do that. Would you have an idea of where I can obtain the directions to access the settings.settings file?
Javeed M ShaikhPosted Oct 26, 2011, 5:07 PM
Sam HobbsPosted Oct 26, 2011, 5:58 PM
So you have found where the connection strings are. Note that the type is "(Connection string)". So to change it, first click in the "Value" column for the connection string row. You will see a small button with an ellipses ("...") in it at the right-side end of the cell; click that button (the ellipses).
scampercatPosted Oct 26, 2011, 5:08 PM
What do you mean by: "
I have posted instructions in the past about doing that, and I think I have already done that for one of your posts.".
What other thread are you referring to for "When you look at the project in the Solution Explorer, does it have a Settings.setting file in the Properties folder of the project? If so, then double-click that. Then refer to my instructions in the other thread."
scampercatPosted Oct 26, 2011, 5:00 PM
Sam HobbsPosted Oct 26, 2011, 4:18 PM
When you look at the project in the Solution Explorer, does it have a Settings.setting file in the Properties folder of the project? If so, then double-click that. Then refer to my instructions in the other thread. If there is not a Settings.setting file, then refer to the other thread for instructions. If there is something you do not understand, then please ask specific questions.
Javeed M ShaikhPosted Oct 26, 2011, 3:42 PM
1. Right Click on the project, click properties.
2. Click on Settings tab on the left, this will open grid on the right hand side. Here you need to enter name of the setting, type, scope and Value.
3. you can later access this settings from C# code as show in my previous post.
scampercatPosted Oct 26, 2011, 3:02 PM
Javeed M ShaikhPosted Oct 26, 2011, 11:48 AM
Properties.Settings.Default.yoursettingname;