Hi ,
Nothing less here is a more closer answer...
I just took it from one of my old code, carefully go through this I can even
give the full code to you.. it has both write and read facility but for a
customized treenode object...
//Starting here.......
// Call the procedure using the TreeView.
private void CallRecursive()
{
str = File.CreateText ("My.xml");
myData = "";
// browse each node recursively.
TreeNodeCollect ion nodes = treeView1.Nodes ;
foreach (TreeNode n in nodes)
{
BrowseRecursive (n, ref myData);
}
str.Write(myDat a);
str.Close();
}
private void BrowseRecursive (TreeNode treeNode, ref string myStr)
{
// browse each node recursively.
if (treeNode.Nodes .Count >0)
myStr += "<" + treeNode.Text + ">";
else
myStr += treeNode.Text;
foreach (TreeNode tn in treeNode.Nodes)
{
BrowseRecursive (tn, ref myStr);
}
if (treeNode.Nodes .Count >0)
myStr += "</" + treeNode.Text + ">";
}
Regards,
Nirosh.
"Robert Gale" <ro*****@gmail. com> wrote in message
news:16******** *************** ***@posting.goo gle.com...
I am writing an RSS reader in C# and I'm trying to write the contents
of a TreeView to an XML file. I have tried using XmlWriter and have
managed to write simple tree structures but I get confused when it
comes to dealing with complex tree structures such as those that have
multiple folders and sub folders.
I have tried searching Code Project and the Net but haven't had much
joy in finding a solution. I have only been using C# for a few months
and my programming knowledge is fairly limited.
Is XmlWriter the best way to write out a TreeView? How would you go
about going through each of the folders and writing the feeds within
them?
If there is anything else that I need to include let me know.