Open the App_Code/FileSystemNodes.cs file in of the demo project.
Replace its content with:
using System;
using System.Web;
using System.IO;
using NineRays.WebControls;
public class FileSystemNodes
{
private const string ROOT_FOLDER = "c:\\";
public static void AddNodes(FlyTreeNodeCollection nodes, string directoryPath)
{
DirectoryInfo directory = new DirectoryInfo(Path.Combine(ROOT_FOLDER, directoryPath));
if (!directory.Exists) return;
DirectoryInfo[] subDirectories = directory.GetDirectories();
foreach (DirectoryInfo subDir in subDirectories)
{
FlyTreeNode ftn = new FlyTreeNode();
ftn.Text = HttpUtility.HtmlEncode(subDir.Name);
ftn.Value = subDir.Name;
nodes.Add(ftn);
try
{
// do not set populate on demand for nodes that have no nested directories
ftn.PopulateNodesOnDemand = subDir.GetFileSystemInfos().Length > 0;
}
catch (Exception ex)
{
// add a child node that shows that there was an exception trying to get its child nodes
AddExceptionNode(ftn.ChildNodes, ex);
}
}
try
{
FileInfo[] files = directory.GetFiles();
foreach (FileInfo file in files)
{
FlyTreeNode ftn = new FlyTreeNode();
ftn.Text = HttpUtility.HtmlEncode(file.Name);
ftn.Value = file.Name;
ftn.ImageUrl = "$file_xml";
nodes.Add(ftn);
}
}
catch (Exception ex)
{
// add a child node that shows that there was an exception trying to get its child nodes
AddExceptionNode(nodes, ex);
}
}
private static void AddExceptionNode(FlyTreeNodeCollection nodes, Exception ex)
{
FlyTreeNode ftn = new FlyTreeNode();
ftn.Text = HttpUtility.HtmlEncode(ex.Message);
ftn.NodeTypeID = "errorType";
nodes.Add(ftn);
}
}
Works for me.