/// Reads a TreeView Control and writes a XML File based on that
///
/// TreeView
///
public string TreeViewToXML(TreeView Tree,string OutputFilepath)
{
TreeNode firstNode = Tree.TopNode;
strBuilder.Append("<Folder name=\"Root\">");
foreach (TreeNode node in firstNode.Nodes)
{
strBuilder.Append("< Folder name=" + node.Text +">");
getChild(node);
strBuilder.Append("</Folder>");
}
strBuilder.Append("</Folder>");
using (StreamWriter sw = File.CreateText(OutputFilepath))
{
sw.Write(strBuilder.ToString());
}
return OutputFilepath;
}
private void getChild(TreeNode node)
{
foreach (TreeNode nodes in node.Nodes)
{
strBuilder.Append("<Folder name=" + nodes.Text + ">");
getChild(nodes);
strBuilder.Append("</Folder>");
}
}
No comments:
Post a Comment