I am creating an application that displays the drives, directories inside them and the sub-directories and the files all in a tree like format.
I am using a TreeView control in C#.net
The problem is that sometimes it doesn't show some of the subdirectories or it skips some of the files and most of the time, it misses the name of the directories.
Suthish NairRank #92 · 22.8K reputationPosted Feb 9, 2011, 8:05 AM EST
public void CreateTreeView(string dirpath, TreeNode treenode) { DirectoryInfo dirInfo = new DirectoryInfo(dirpath); foreach (DirectoryInfo dirinfo in dirInfo.GetDirectories()) { TreeNode tn = new TreeNode(dirinfo.Name); CreateTreeView(dirinfo.FullName, tn); treenode.Nodes.Add(tn); } foreach (FileInfo fi in dirInfo.GetFiles()) { TreeNode tn = new TreeNode(fi.Name); treenode.Nodes.Add(tn); } }Tushar Malhotra6 reputationPosted Feb 10, 2011, 3:54 AM EST
Suthish NairRank #92 · 22.8K reputationPosted Feb 10, 2011, 10:26 PM EST