-1

so I am trying to populate a treeview with folders and files from a given directory, but when the given path is a drive, example: path = "E:/", it gives me a UnauthorizedAccessException error. The code comes from this other question here: Populate TreeView with file system directory structure

As suggested in comments, I tried using a try catch for this issue, an the error is gone and everything works, however, things like $RECYBLEBIN, Systemvolumeinformation and Binary.data appear as nodes. How to make it so they dont?

Ravi Mattar
  • 179
  • 1
  • 12

1 Answers1

0

If you've based your code on that post, you could use the DirectoryInfo.Attributes property to check for Hidden or System values, for example, so you could let those items out of your TreeView list.

Pedro Gaspar
  • 777
  • 8
  • 35