예제 #1
0
        private void GetAllDirectories()
        {
            hdnPathTextBoxId.Value = Request.QueryString["txtSQLBackupPathID"].ToString();
            DriveInfo[] drives = DriveInfo.GetDrives();
            foreach (DriveInfo drive in drives)
            {
                TreeNode onjParent = new TreeNode(drive.ToString(), drive.ToString());
                onjParent.PopulateOnDemand = true;
                TrDirectoryView.Nodes.Add(onjParent);
            }

            TrDirectoryView.CollapseAll();
        }
예제 #2
0
        public TreeNode OutputDirectory(System.IO.DirectoryInfo directory, TreeNode parentNode)
        {
            if (directory == null)
            {
                return(null);
            }
            // create a node for this directory
            TreeNode DirNode = new TreeNode(directory.Name);

            // get subdirectories of the current directory
            System.IO.DirectoryInfo[] SubDirectories = null;
            TreeNode tree = TrDirectoryView.FindNode(directory.Name);

            if (tree == null)
            {
                try
                {
                    SubDirectories = directory.GetDirectories();
                }
                catch (Exception e)
                {
                }

                if (SubDirectories != null)
                {
                    for (int DirectoryCount = 0; DirectoryCount < SubDirectories.Length; DirectoryCount++)
                    {
                        OutputDirectory(SubDirectories[DirectoryCount], DirNode);
                    }
                }
            }
            if (parentNode == null)
            {
                return(DirNode);
            }
            else
            {
                if (!(DirNode.ChildNodes.Count > 0))
                {
                    DirNode.ImageUrl = "~/Images/Folder.jpg";
                }

                parentNode.ChildNodes.Add(DirNode);
                return(parentNode);
            }
        }