using System.Drawing;
using System.Text;
using System.Threading;
using System.IO;
public void ListDir(string src, TreeNode d){
try{
DirectoryInfo dinfo = new DirectoryInfo(@"" + src);
FileInfo[] finfo = dinfo.GetFiles();
for (int j = 0; j < finfo.Length; j++)
{
d.Nodes.Add(@"" + finfo[j].Name);
}
DirectoryInfo[] dname = dinfo.GetDirectories();
TreeNode[] treend = new TreeNode[dname.Length];
for (int i = 0; i < dname.Length; i++)
{
treend[i] = new TreeNode(dname[i].Name);
d.Nodes.Add(treend[i]);
}
for (int i = 0; i < dname.Length; i++)
{
ListDir(dname[i].FullName, treend[i]);
Thread.Sleep(5);
}
}
Saturday, April 24, 2010
Traversing and adding file structure to a tree node
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment