visual studio - C# populating treeview and getting errors on directories that I do not have permission to read -


I am creating a Tree View Control, C # Visual Studio 8 using this code:

  Private TreeNode Traverse Directory (String Path) {TriNode Results = New Triode (Path); Foreign currency (sub subdirectory in directory .gate directory (path)) {result.Nodes.Add (TraverseDirectory (subdirectory)); } Return results; }  

The problem is that if I click on it, then c: / drive gets an error on the directory that I do not have permission to read. My question is, How would I avoid showing the directories to which I do not have permission? How do I test for it and then ask the app to ignore them?

Thanks R.

for a simplified approach:

  triode results; Try {string [] subdirs = Directory.GetDirectories (path); Result = New tree node (path); Foreign (subdirs in string subdirectory) {TreeNode children = TraverseDirectory (subdir); If (child! = Null) {result.Nodes.Add (child); }} Return result; } Hold (search obvious exception) {// undiscovered DIR result = null; } Return results;  

Individually I will try to load some kind of lazy, but include Dummy Nodes with standard TreeView in IIRC Includes doing.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -