public ObservableCollection<Node> Items { get; }
public ObservableCollection<Node> SelectedItems { get; }
public string strFolder { get; set; }
public MainWindowViewModel()
strFolder = @"C:\Users\hooty\Desktop"; // EDIT THIS FOR AN EXISTING FOLDER
Items = new ObservableCollection<Node>();
Node rootNode = new Node(strFolder);
rootNode.Subfolders = GetSubfolders(strFolder);
public ObservableCollection<Node> GetSubfolders(string strPath)
ObservableCollection<Node> subfolders = new ObservableCollection<Node>();
string[] subdirs = Directory.GetDirectories(strPath, "*", SearchOption.TopDirectoryOnly);
foreach (string dir in subdirs)
Node thisnode = new Node(dir);
if (Directory.GetDirectories(dir, "*", SearchOption.TopDirectoryOnly).Length > 0)
thisnode.Subfolders = new ObservableCollection<Node>();
thisnode.Subfolders = GetSubfolders(dir);
subfolders.Add(thisnode);
public ObservableCollection<Node> Subfolders { get; set; }
public string strNodeText { get; }
public string strFullPath { get; }
public Node(string _strFullPath)
strFullPath = _strFullPath;
strNodeText = Path.GetFileName(_strFullPath);