Hi,
I am populating a treeview control, c# visual studio 8, using this code:
private TreeNode TraverseDirectory(string path)
{
TreeNode result = new TreeNode(path);
foreach (var subdirectory in Directory.GetDirectories(path))
{
result.Nodes.Add(TraverseDirectory(subdirectory));
}
return result;
}
The trouble is that if I click on, say the c:/ drive I get an error on directories that I do not have permission to read. My question is, how do I avoid showing those directories that I do not have permission for? How would I test for that and then tell the app to ignore them?
Thanks R.