• 小型资源管理器


     private void Form1_Load(object sender, EventArgs e)
            {
                //添加根
                TreeNode tr = new TreeNode();
                tr.Tag = "D:\";  ///完整路径
                    tr.Text="D:\";
                treeView1.Nodes.Add(tr);
            }

            private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
            {
                TreeNode bo = treeView1.SelectedNode;
                string nods = bo.Tag.ToString();
                DirectoryInfo info = new DirectoryInfo(nods);//创建目录对象
                DirectoryInfo[] dirs = info.GetDirectories();//得到子目录的集合
                //循环绑定TreeView
                bo.Nodes.Clear();
                foreach (DirectoryInfo item in dirs)
                {
                    TreeNode di = new TreeNode();
                    di.Text = item.Name;
                    di.Tag = item.FullName;
                    bo.Nodes.Add(di);   //把节点添加到选择节点中
                }

              FileInfo[] fi = info.GetFiles();
                listView1.Items.Clear();
                //循环绑定ListView上
                foreach (FileInfo item in fi)
                {
                    ListViewItem lv = new ListViewItem();
                    lv.Text = item.Name;
                    lv.SubItems.Add(item.Length * 1.0 / 1024 + "kb");
                    lv.SubItems.Add(item.Extension);
                    lv.SubItems.Add(item.FullName);
                    listView1.Items.Add(lv);
                }   

  • 相关阅读:
    整理15款实用javascript富文本编辑器
    深度选择器
    字帖工具 免费打印 生成pdf
    说说市场经济
    看windows变化的感想
    观念总结
    Bittly 不只是一个串口调试助手
    [POI2013] SPAWalk 引理证明
    JAVA基础之泛型
    macaca,request,unitest,flask 框架介绍和理解
  • 原文地址:https://www.cnblogs.com/caiguoxin/p/8900693.html
Copyright © 2020-2023  润新知