private void buttonNewFolder_Click(object sender, RoutedEventArgs e) { NewFolderDialog newDia = new NewFolderDialog(); newDia.ShowDialog(); String folderName = newDia.FolderTitle; String path = null; if (ExplorerTree.SelectedItem != null) { if (!((TreeViewItem)ExplorerTree.SelectedItem).Tag.ToString().EndsWith(".txt")) { path = ((TreeViewItem)ExplorerTree.SelectedItem).Tag.ToString(); } } controller.CreateFolder(folderName, path); }