Пример #1
0
        private static void AddRootNodes(OPMTreeView tree, ImageList imageList, bool getIcons, bool showSpecialFolders)
        {
            CursorHelper.ShowWaitCursor(tree, true);

            tree.Nodes.Clear();

            List <string> roots = new List <string>();

            try
            {
                System.IO.DriveInfo[] drives = System.IO.DriveInfo.GetDrives();
                foreach (System.IO.DriveInfo di in drives)
                {
                    roots.Add(di.RootDirectory.FullName);
                }

                if (showSpecialFolders)
                {
                    foreach (Environment.SpecialFolder sf in SpecialFolders)
                    {
                        string path = Environment.GetFolderPath(sf, Environment.SpecialFolderOption.Create);
                        if (Directory.Exists(path))
                        {
                            roots.Add(path);
                        }
                    }
                }
            }
            catch
            {
            }

            foreach (string dir in roots)
            {
                TreeNode rootNode = CreateTreeNode(dir, imageList, true);
                tree.Nodes.Add(rootNode);
                CheckForSubDirs(rootNode, imageList);
            }

            CursorHelper.ShowWaitCursor(tree, false);
        }
Пример #2
0
        private static void AddRootNodes(OPMTreeView tree, ImageList imageList, bool getIcons, bool showSpecialFolders)
		{
            CursorHelper.ShowWaitCursor(tree, true);

			tree.Nodes.Clear();

            List<DirectoryInfo> roots = new List<DirectoryInfo>();

            try
            {
                System.IO.DriveInfo[] drives = System.IO.DriveInfo.GetDrives();
                foreach (System.IO.DriveInfo di in drives)
                {
                    roots.Add(di.RootDirectory);
                }

                if (showSpecialFolders)
                {
                    foreach (Environment.SpecialFolder sf in SpecialFolders)
                    {
                        string path = Environment.GetFolderPath(sf, Environment.SpecialFolderOption.Create);
                        if (Directory.Exists(path))
                        {
                            roots.Add(new DirectoryInfo(path));
                        }
                    }
                }
            }
            catch
            {
            }
            
            foreach (DirectoryInfo di in roots)
            {
                TreeNode rootNode = CreateTreeNode(di, imageList, true);
                tree.Nodes.Add(rootNode);
                CheckForSubDirs(rootNode, imageList);

                /*
                try
                {
                    foreach (DirectoryInfo sdi in di.EnumerateDirectories())
                    {
                        TreeNode tn = CreateTreeNode(sdi, imageList, getIcons);
                        rootNode.Nodes.Add(tn);
                        
                        CursorHelper.ShowWaitCursor(tree, true);
                    }
                }
                catch
                {

                }*/
            }

            CursorHelper.ShowWaitCursor(tree, false);
		}
Пример #3
0
        public static void PopulateTree(OPMTreeView tree, ImageList imageList, bool showSpecialFolders)
		{
			tree.Nodes.Clear();
            AddRootNodes(tree, imageList, true, showSpecialFolders);
		}
Пример #4
0
 public static void PopulateTree(OPMTreeView tree, ImageList imageList, bool showSpecialFolders)
 {
     tree.Nodes.Clear();
     AddRootNodes(tree, imageList, true, showSpecialFolders);
 }