I am using this function which is a recursive loop, try it, it is simple.
void AddNode(TreeNode node, DirectoryInfo di)
{
foreach (DirectoryInfo d in di.GetDirectories())
{
TreeNode FolderNode = new TreeNode(d.Name);
FolderNode.SelectAction = TreeNodeSelectAction.Expand;
node.ChildNodes.Add(FolderNode);
foreach (FileInfo fi in d.GetFiles())
{
TreeNode FileNode = new TreeNode(fi.Name);
FileNode.SelectAction = TreeNodeSelectAction.Select;
string ftpPath = fi.FullName.Replace(@"\\o7r38-5m0\r3d10f9er25h$\", @"ftp://192.168.2.128/Archive/");
ftpPath = ftpPath.Replace(@"\", @"/");
FileNode.NavigateUrl = "JavaScript:ope('"+ftpPath+"')";
FolderNode.ChildNodes.Add(FileNode);
}
AddNode(FolderNode, d);
}
}
Thanks