protected void PopulateNode(TreeNode aNode)
{
this.Cursor = Cursors.WaitCursor; // Set up the wait cursor
string strDir = BuildDirectory(aNode); // Build the directory tree string from the tree node
Directory Dir = new Directory(strDir); // Use the Directory class to get the files and directory names in the directory
int count = 0;// Get each directory name and add it as a directory folder tree node
for (int i = 0; i < Dir.GetDirectories().Length; i++)
{
TreeNode ChildNode = new TreeNode(Dir.GetDirectories()[i].Name, 1,0);
aNode.Nodes.Add(i, ChildNode);
count++;
}// Get each file name and add it as a file tree node
for (int i = 0; i < Dir.GetFiles(m_strFilter).Length; i++)
{
TreeNode ChildNode = new TreeNode(Dir.GetFiles(m_strFilter)[i].Name, 2,2);
aNode.Nodes.Add(i+count, ChildNode);
} aNode.Expand(); // 显示子结点
this.Cursor = Cursors.Arrow; //设
}
{
this.Cursor = Cursors.WaitCursor; // Set up the wait cursor
string strDir = BuildDirectory(aNode); // Build the directory tree string from the tree node
Directory Dir = new Directory(strDir); // Use the Directory class to get the files and directory names in the directory
int count = 0;// Get each directory name and add it as a directory folder tree node
for (int i = 0; i < Dir.GetDirectories().Length; i++)
{
TreeNode ChildNode = new TreeNode(Dir.GetDirectories()[i].Name, 1,0);
aNode.Nodes.Add(i, ChildNode);
count++;
}// Get each file name and add it as a file tree node
for (int i = 0; i < Dir.GetFiles(m_strFilter).Length; i++)
{
TreeNode ChildNode = new TreeNode(Dir.GetFiles(m_strFilter)[i].Name, 2,2);
aNode.Nodes.Add(i+count, ChildNode);
} aNode.Expand(); // 显示子结点
this.Cursor = Cursors.Arrow; //设
}
解决方案 »
- dotnetbar的superTabControl中如何去掉重复的tab!!
- 计算价钱
- 尝试读取或写入受保护的内存。这通常指示其他内存已损坏。
- 一个小问题
- FileStream的一点小疑问
- 在新建命名空间使用Session问题
- 关于c#连接sql sever数据库的问题
- C# 如何以存在的Excel模板导出所需要的表格(保持模板格式并需要添加数据库数据),数据从Access数据库导出;最好能在程序中添加打印预览功能(分可以加)
- PicTureBox控件问题!
- 请问一个C#中关于ListView控件的一个问题,请各位大吓多多帮助!!!!
- 如何把Unix下的时间戳(timestamp)转化为DateTime类型??
- ********************如何制作这样的Datrgrid列:*********************
{
TreeNode theNode = aNode;
string strDir = "";
// Cycle through the node and all its parents to build the full path of the directory while (theNode != null)
{
if (theNode.Text[theNode.Text.Length - 1] != '\\')
{
strDir = "\\" + strDir;
} strDir = theNode.Text + strDir;
theNode = theNode.Parent;
}return strDir;}
{
// check to see if the selected node is already populated
if (e.node.Nodes.Count > 0 || e.node.ImageIndex == 2)
{
return;
}// The node is not populated, so populate the selected node PopulateNode(e.node);
}protected void button1_Click (object sender, System.EventArgs e)
{
label3.Text = dirTree1.Path;
label4.Text = dirTree1.FileName;
}
我想当你们到这种地步的时候头已经大了吧!!!
呵呵,我给你们说个好的方法,也有助你们学习,最新我校用个这软件开发出几个管理软件来供大家参观。
IT高手网站 ——www.topit.tk
豫信软件公司网站——www.zzyxsoft.com
学校网站——www.haetc.com
可以去论坛发贴或者发E-mail:
[email protected]