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 :
and my folderbrowse code is :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); }
i need to add some code to this part :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; } }
{
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![]()




Reply With Quote