Last post Mar 11, 2008 02:34 AM by poidda
Mar 08, 2008 06:02 PM|jimmyfingers101|LINK
I was wondering if anyone could help me with a way to create and xml document based on a folder structure on my local machine? It would also need to be recursive.
Mar 08, 2008 06:39 PM|ASP.NET Dev|LINK
Please could you post the required xml sample.
<file id="web.config" />
<folder id="App_Code" />
You have to use DirectoryInfo class to get all directories/folders within in given directory/folder.
Mar 08, 2008 07:02 PM|jimmyfingers101|LINK
Ok I've sorted out how to create an xml file from my folders, but now when I try to bind it to a TreeView control it just lists a tree of 'Folders' and 'Files' instead of the actual names for the folders and files. My xml document is fine though. Here is
the xml representation of my VS2005 folder:
Mar 08, 2008 07:16 PM|ASP.NET Dev|LINK
<asp:TreeView ID="TreeView1" runat="server" DataSourceID="XmlDataSource1">
<asp:TreeNodeBinding TextField="name" ValueField="name" />
<asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="~/App_Data/Folders.xml">
And remove the <?xml version="1.0" standalone="yes" ?> from ur xml.
Mar 08, 2008 07:30 PM|jimmyfingers101|LINK
Yey! Thank you so much for the help.
Mar 08, 2008 07:52 PM|ASP.NET Dev|LINK
Please mark it as answer if it helped you.
Mar 10, 2008 10:39 AM|jimmyfingers101|LINK
On a side note however, although this works great with a web app, if I wanted to use this on a Windows Forms app how do you bind an xml doc as a TreeView control's data source? From what I can see you don't appear to have the same binding options available
Mar 11, 2008 02:34 AM|poidda|LINK
jimmyfingers101, can you post how you created your XML file please? I'm wanting to do the same thing.