Exemplo n.º 1
0
        private void CreateRoot(string rootPath)
        {
            root = new FolderNode()
            {
                FolderDirectory = rootPath
            };
            GetChildNode(root);
            dir = new ObservableCollection <FolderNode>();
            dir.Add(root);

            treeDirectory.ItemsSource = dir;
        }
Exemplo n.º 2
0
 private void GetChildNode(FolderNode parent, string currentPath = "")
 {
     try
     {
         foreach (string folder in Directory.EnumerateDirectories(parent.FolderDirectory))
         {
             FolderNode folderNode = new FolderNode()
             {
                 FolderDirectory = folder
             };
             parent.ChildFolders.Add(folderNode);
         }
         foreach (string file in Directory.EnumerateFiles(parent.FolderDirectory))
         {
             FolderNode folderNode = new FolderNode()
             {
                 FolderDirectory = file
             };
             folderNode.Type = NodeType.File;
             parent.ChildFolders.Add(folderNode);
         }
     }
     catch { }
 }
Exemplo n.º 3
0
        private void treeDirectory_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e)
        {
            FolderNode currentNode = (treeDirectory.SelectedItem as FolderNode);

            GetChildNode(currentNode);
        }