Example #1
0
        public void BuildParentNode()
        {
            DirectoryInfo DIR = new DirectoryInfo(GlobalVariable.objMainWindowVM.SavedData.DriveLetter);

            LsRootTreeViewItem = new ObservableCollection <RootTreeViewItem>();

            RootTreeViewItem Parent = new RootTreeViewItem();

            Parent.Header     = DIR.Name;
            Parent.Path       = DIR.FullName;
            Parent.Type       = DIR.GetType().Name;
            Parent.IsExpanded = false;
            LsRootTreeViewItem.Add(Parent);

            Parent.LsChildrenNode = new ObservableCollection <RootTreeViewItem>();
            foreach (DirectoryInfo DR in DIR.GetDirectories())
            {
                if (!DR.Attributes.ToString().Contains("Hidden"))
                {
                    RootTreeViewItem ParenNode = new RootTreeViewItem();
                    ParenNode.Header     = DR.Name;
                    ParenNode.Path       = DR.FullName;
                    ParenNode.Type       = DR.GetType().Name;
                    ParenNode.IsExpanded = false;
                    Parent.LsChildrenNode.Add(ParenNode);

                    ParenNode.LsChildrenNode = new ObservableCollection <RootTreeViewItem>();
                    foreach (DirectoryInfo CDIR in DR.GetDirectories())
                    {
                        RootTreeViewItem ChildrenNode = new RootTreeViewItem();
                        ChildrenNode.IsExpanded = false;
                        ChildrenNode.Header     = CDIR.Name;
                        ChildrenNode.Path       = CDIR.FullName;
                        ChildrenNode.Type       = CDIR.GetType().Name;
                        ParenNode.LsChildrenNode.Add(ChildrenNode);
                    }
                }
            }
            foreach (FileInfo DR in DIR.GetFiles())
            {
                if (!DR.Attributes.ToString().Contains("Hidden"))
                {
                    RootTreeViewItem ParenNode = new RootTreeViewItem();
                    ParenNode.Header     = DR.Name;
                    ParenNode.Path       = DR.FullName;
                    ParenNode.Type       = DR.GetType().Name;
                    ParenNode.IsExpanded = false;
                    Parent.LsChildrenNode.Add(ParenNode);
                }
            }
        }