日期:2014-05-17 浏览次数:20859 次
//根据文件夹创建结点
private void BindChilddir(TreeNode p_node)
{
string node_path = p_node.Tag.ToString();
System.IO.DirectoryInfo f_dir = new System.IO.DirectoryInfo(node_path);
System.IO.FileSystemInfo[] fin_fos = f_dir.GetFileSystemInfos();
int length = fin_fos.Length;
for (int i = 0; i < length; ++i )
{
//string type = fin_fos[i].GetType().ToString();
TreeNode node = new TreeNode();
node.Text = fin_fos[i].Name;
node.Tag = fin_fos[i].FullName;
p_node.Nodes.Add(node);
//是文件夹时才递归调用自己
if ("System.IO.DirectoryInfo" == fin_fos[i].GetType().ToString())
{
BindChilddir(node);
}
else
{
node.ImageIndex = 1;
}
}