Ejemplo n.º 1
0
        private void form_Load(object sender, EventArgs e)
        {
            Tips.Text = "读取目录..";
            DirectoryInfo root = new DirectoryInfo(WindowsPath);

            foreach (DirectoryInfo i in root.GetDirectories())
            {
                Tips.Text     = "读取" + i.Name;
                LoadBar.Value = 0;
                DirDescription p    = new DirDescription(i.Name);
                Thread         read = new Thread(new ParameterizedThreadStart(readDir));
                read.Start(p);
                while (p.getFindMissionState() == false)
                {
                    LoadBar.Value = p.getFindMissionBar();
                }
                LoadBar.Value = p.getFindMissionBar();
                dir.Add(p);
                TreeNode f = p.getDirTree();
                if (f != null)
                {
                    treeView1.Nodes.Add(p.getDirTree());
                }
            }
            LoadBar.Visible  = false;
            Tips.Text        = "输入端口号后点启动";
            Port.Visible     = true;
            StartBut.Visible = true;
            StartBut.Text    = "启动";
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 让该目录对象开始生成目录结构
        /// 返回FALSE表示目录不存在,返回TRUE表示生成完毕
        /// </summary>
        public bool findChild()
        {
            string path = WindowsPath + "\\" + getDirPath();


            if (Directory.Exists(path) == false)
            {
                return(false);
            }
            int Files = Directory.GetFiles(path).Length;       //当前目录下的文件数量
            int Dirs  = Directory.GetDirectories(path).Length; //当前目录下的目录数量

            LoadMissionMax = Files + Dirs;
            LoadMissionNow = 0;
            DirectoryInfo Dir = new DirectoryInfo(path);

            foreach (FileInfo i in Dir.GetFiles())
            {
                File.Add(new FileDescription(i.FullName, getDirPath()));
                LoadMissionNow++;
            }
            foreach (DirectoryInfo i in Dir.GetDirectories())
            {
                DirDescription tmp = new DirDescription(i.Name, this);
                Child.Add(tmp);
                tmp.findChild();
                LoadMissionNow++;
            }

            findMissionOK = true;
            return(true);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 返回最顶层父级目录对象
        /// </summary>
        /// <returns></returns>
        public DirDescription getSuperRoot()
        {
            DirDescription tmp = this;

            if (tmp.Root == null)
            {
                return(tmp);
            }
            while (tmp.Root != null)
            {
                tmp = tmp.getRoot();
            }
            return(tmp);
        }
Ejemplo n.º 4
0
        private void readDir(object obj)
        {
            DirDescription dir = (DirDescription)obj;

            dir.findChild();
        }
Ejemplo n.º 5
0
 /// <summary>
 /// 根目录构造函数
 /// 用于描述一个具有父目录的目录
 /// </summary>
 /// <param name="rootDir">父目录的DirDescription对象引用</param>
 /// <param name="dirname">该目录的名字</param>
 public DirDescription(string dirname, DirDescription rootDir)
 {
     Root    = rootDir;
     DirName = dirname;
     DirPath = Root.getDirPath() + "\\" + dirname;
 }
Ejemplo n.º 6
0
        private bool findMissionOK          = false;                                                     //是否已生成完毕目录结构

        /// <summary>
        /// 根目录构造函数
        /// 用于描述一个目录的顶层目录
        /// </summary>
        /// <param name="dirname">根目录的名字</param>
        public DirDescription(string dirname)
        {
            DirName = dirname;
            DirPath = "";
            Root    = null;
        }