save the modified data?

bi7br34k3r

New member
Joined
Aug 17, 2013
Messages
1
Programming Experience
Beginner
Hi all,


I'm currently building my first application in C# and I hit a wall at the final step of the application. Let me start by explaining the goal of the application.

This is a simple application that I'm building to read and edit an XML file. I have created a form with two buttons and four text boxes. The first button opens the XML file and displays the path and file name in the first text box. The three text boxes show the values of three elements within the XML file which will be edited and then saved. The second button (as you may have already guessed) is meant to save the modified data to the original XML file.

The very last part is where I am stuck. Since the elements are all called "endpoint" and the values I am pulling are "address" I used a list to separate the data. How would I go about building the save button to save any changes in those text boxes to the original values?

Here is a snippet of the code:

{ AgentConfig.Filter = "Agent.exe.config (*.config)|*.config";
if (AgentConfig.ShowDialog() == DialogResult.OK)
{
textBox1.Text = AgentConfig.FileName;
}


var addresses = XDocument.Load(AgentConfig.FileName)
.Descendants("endpoint")
.Select(x => (string)x.Attribute("address"))
.ToList();


textBox2.Text = addresses[0];
textBox3.Text = addresses[1];
textBox4.Text = addresses[2];
}


private void button2_Click(object sender, EventArgs e)
{
XDocument.Load(AgentConfig.FileName)
}

Any help would definitely be appreciated. :)


EDIT: Just added this to my code:

private void button2_Click(object sender, EventArgs e)
{
SaveFileDialog SF = new SaveFileDialog();
if (SF.ShowDialog() == DialogResult.OK)
{


}
}
 
Last edited:

Latest posts

Back
Top Bottom