You might want to consider what happens if the
DIR
elements are not in the expected order, or any of the paths are missing.
string filePath = Path.GetFullPath(@".\programconfig.xml");
XElement doc = XElement.Load(filePath);
Dictionary<string, string> paths = doc.Descendants("DIR").ToDictionary(
d => (string)d.Element("name"),
d => (string)d.Element("path"),
StringComparer.OrdinalIgnoreCase);
string value;
if (paths.TryGetValue("Installation Path", out value))
{
t_Installazione.Text = value;
}
if (paths.TryGetValue("Temp directory", out value))
{
t_Temp.Text = value;
}
if (paths.TryGetValue("Test List Path", out value))
{
t_testlist.Text = value;
}