Hi all,
Wondering if someone can help with a best practises can of help that I need.
Basically, I've got a settings file that contains two email addresses. I current retrieve this out of the settings file as a string, and then split the string by a ',' character, thus getting a string array containing the appropriate data.
Is it possible (and how would I!?) have these as two seperate entries? I did do a couple of Googles but to no avail.
Cheers,
Greg
Loading
Ryan AlfordPosted Dec 14, 2007, 10:00 AM
What I would really like in the XML is:
GregPosted Dec 13, 2007, 11:25 AM
I currently have a setting, lets say MyString which has two values for example 'A' and 'B'. So in my settings view I currently have MyString A,B.
Pretend in my application I have a string entered by the user which could be A, B or C. I want to compare to see if its one of the values in my settings file. I'm currently having to read the setting value:
string settingStrings = Workspace.Properties.Default.MyString;
string[] settings = settingStrings.Split(",");
foreach (string setting in settings)
{
if (userstring == setting)
{
// do something
}
}
In the XML file for the app.config though there is a single entry, something like:
What I would really like in the XML is:
Is this possible? Or would I need to write my own XML reader for this instance?
Thanks for reading!
Cheers,
Greg
Scott LyslePosted Dec 13, 2007, 11:17 AM
If you double click on Properties in the solution explorer, and then click on the 'Settings' tab. You will see a grid that will allow you to setup application wide and user controlled settings.
You can get or set the values of a user setting at run time. To access one, this will work (as an example for a setting called email).
MessageBox.Show(Properties.Settings.Default.email);To set one, this will work:
Properties.Settings.Default.email = textBox1.Text; Properties.Settings.Default.Save();