zoukankan      html  css  js  c++  java
  • web页面建立目录浏览器

    浏览整个服务器的目录:protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                foreach (System.IO.DriveInfo drive in DriveInfo.GetDrives())
                {
                    TreeNode node = new TreeNode();
                    node.Value = drive.Name;
                    if (drive.IsReady)
                    {
                        node.Text = drive.Name + "  free";
                        LoadDirectories(node, drive.Name);
                    }
                    else
                        node.Text = drive.Name + "   not ready";
                    this.TreeView1.Nodes.Add(node);
                }
            }
            this.TreeView1.CollapseAll();

        }
        private void LoadDirectories(TreeNode parent, string path)
        {
            DirectoryInfo directory = new DirectoryInfo(path);
            try
            {
                foreach (DirectoryInfo d in directory.GetDirectories())
                {
                    TreeNode node = new TreeNode(d.Name, d.FullName);
                    parent.ChildNodes.Add(node);
                    LoadDirectories(node, d.FullName);
                }

            }
            catch (System.UnauthorizedAccessException e)
            {
                parent.Text += " (Acess Denied)";
            }
            catch (IOException e)
            {
                parent.Text += "(UNknown error:" + e.Message + ")";
            }
        }

  • 相关阅读:
    python爬虫常见面试题(二)
    python爬虫常见面试题(一)
    回首2018,展望2019
    PDF编辑软件PDFGuru
    打字机NoisyTyper
    文本标注系统
    logstash配置
    服务器上安装python3
    scrapy自调度方案
    前端项目配置nginx配置
  • 原文地址:https://www.cnblogs.com/jinyu20180311/p/10312402.html
Copyright © 2011-2022 走看看