Results 1 to 4 of 4

Thread: writng the value of a FolderBrowserDialog to setting.xml

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2004
    Posts
    5

    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

  2. #2

    Thread Starter
    New Member
    Join Date
    Sep 2004
    Posts
    5
    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

  3. #3
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690
    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

  4. #4

    Thread Starter
    New Member
    Join Date
    Sep 2004
    Posts
    5
    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
  •  



Click Here to Expand Forum to Full Width