I am getting a stack overflow, when I try to create a Tree View using WinForms.
private void createFeatureTree()
FeatureTree.Nodes.Add(createTreeNode(new DirectoryInfo(starting directory path)));
private TreeNode createTreeNode(DirectoryInfo directory)
var directoryNode = new TreeNode(directory.Name);
foreach (var dir in directory.GetDirectories())
foreach (var file in directory.GetFiles())
Change a call
And it should work. The reason you are getting "StackOverflowException" is that you always call createTreeNode method on directory variable passed in, not on its subdirectories (which, eventually, there would be none when you are at the leaf level).
Basicaly, if you pass in "C:\", you constantly call createTreeNode on "C:\" and it never ends.