|
-
Sep 17th, 2004, 05:04 AM
#1
Thread Starter
New Member
writng the value of a FolderBrowserDialog to setting.xml
firstly Can i say hello to all members ( my first post )
now for my question..
i want to save the value of a FolderBrowserDialog to a settings.xml file
my current xml save code is as follows :
Code:
private void WriteAppSetting( string strFilePath, string strKey, string strValue )
{
XmlDocument xmlDoc = new XmlDocument();
XmlNode xmlSettingsNode;
XmlElement xmlSettingsElement = xmlDoc.DocumentElement;
xmlDoc.Load ( strFilePath );
xmlSettingsNode = xmlDoc.SelectSingleNode ( "/configuration/appSettings" );
for ( int nDex=0; nDex < xmlSettingsNode.ChildNodes.Count; nDex++ )
{
if ( xmlSettingsNode.ChildNodes[nDex].Attributes["key"].Value.ToString() == strKey )
{
xmlSettingsNode.ChildNodes[nDex].Attributes["value"].Value = strValue;
break;
}
}
xmlDoc.Save(strFilePath);
}
and my folderbrowse code is :
Code:
private void button2_Click(object sender, System.EventArgs e)
{
System.Windows.Forms.FolderBrowserDialog fbd = new System.Windows.Forms.FolderBrowserDialog();
DialogResult result = fbd.ShowDialog(this);
if( result == DialogResult.OK )
{
textBox1.Text = fbd.SelectedPath;
}
}
i need to add some code to this part :
{
textBox1.Text = fbd.SelectedPath;
.......code here......
}
but i am unsure ( being a newbie)
the following code works fine for this but i need it to add the folder that is selected and not what value is in the line of code ( My Test String changed ) ?
WriteAppSetting ( @"config.xml", "FolderPath", "My Test String changed" );
can somebody help , thanks
-
Sep 17th, 2004, 07:27 AM
#2
Thread Starter
New Member
how would i insert the fbd.SelectedPath command into the line
Code:
WriteAppSetting ( @"config.xml", "FolderPath", "My Test String changed" );
is that how it would work ?
Thanks MrXs
-
Sep 17th, 2004, 07:15 PM
#3
Frenzied Member
I hope I understand you correctly. If you're asking how to put the value of the selected folder as an argument into your method, you can do something like:
Code:
WriteAppSetting ( @"config.xml", "FolderPath", fbd.SelectedPath );
It looks like that in your code fbd is not accessable there, so since you saved the value in the text box, you could use the .Text property instead.
After reading your posts a couple of times, I'm not really clear on your problem. I hope this helps, though.
Mike
-
Sep 18th, 2004, 07:45 AM
#4
Thread Starter
New Member
thanks m8
i get the idea now and will work on that - i was unsure being new to c#
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
|