-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathReadToTreeView.cs
42 lines (38 loc) · 1.25 KB
/
ReadToTreeView.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
namespace ProjektGenerator_Test1
{
class ReadToTreeView
{
public void loadIntoTreeView(string path, TreeView treeView)
{
foreach (string s in Directory.EnumerateDirectories(path))
{
TreeViewItem item = new TreeViewItem();
item.Header = s.Substring(s.LastIndexOf('\\') + 1);
item.Tag = s;
item.FontWeight = FontWeights.Normal;
FillTreeView(item, s);
treeView.Items.Add(item);
}
}
internal void FillTreeView(TreeViewItem parentItem, string path)
{
foreach (string str in Directory.EnumerateDirectories(path))
{
TreeViewItem item = new TreeViewItem();
item.Header = str.Substring(str.LastIndexOf('\\') + 1);
item.Tag = str;
item.FontWeight = FontWeights.Normal;
parentItem.Items.Add(item);
FillTreeView(item, str);
}
}
}
}