public void WriteDataToXML(string filePath, string[] fieldsList, string[] fieldsValue)
{
try
{
if (fieldsList.Length.Equals(fieldsValue.Length))
{
int arrayLength = fieldsList.Length;
if (File.Exists(filePath))
{
XDocument xDocument;
xDocument = XDocument.Load(filePath);
XElement rootElement = new XElement("Details");
XElement dataElement = new XElement("Data");
for (int count = 0; count < arrayLength; count++)
{
XElement element = new XElement(fieldsList[count], fieldsValue[count]);
dataElement.Add(element);
}
xDocument.Element("Details").Add(dataElement);
xDocument.Save(filePath);
}
else
{
XElement rootElement = new XElement("Details");
XElement dataElement = new XElement("Data");
for (int count = 0; count < arrayLength; count++)
{
XElement element = new XElement(fieldsList[count], fieldsValue[count]);
dataElement.Add(element);
}
rootElement.Add(dataElement);
rootElement.Save(filePath);
}
}
}
catch (Exception ex) { }
}
Thursday, February 16, 2012
Subscribe to:
Posts (Atom)
Motivational qoutes
पूरे विश्वास के साथ अपने सपनों की तरफ बढ़ें। वही ज़िन्दगी जियें जिसकी कल्पना आपने की है।
-
H ere is the code example given to add Image column in Datagrid control dynamically at run time in WPF. public void AddColumnsToDataGrid(...
-
S ome times we need to add some controls in a container at run time. Here is the coding logic given to add CheckBox column in Datagrid cont...
-
H ow to add TreeViewItem dynamically in TreeView control in WPF. Here is the coding example given below to add TreeViewItem in TreeView con...