DirectoryInfo.GetDirectories()
-
Evening guys, Hopefully a quick question. I am trying to iterate all sub directories within a folder using the DirectoryInfo.GetDirectories() This isall fine until the search hits a directory that I do not have permisions for, unfortunately at this point an UnathorisedAccessException is thrown which is perfecty understandable. What I would like to do is retrieve a list of directories that I do have permission for and ignore any that I don't. Any ideas? Many thanks Paul ps, what event is it thrown for the enter key on a text box??
Paul
-
Evening guys, Hopefully a quick question. I am trying to iterate all sub directories within a folder using the DirectoryInfo.GetDirectories() This isall fine until the search hits a directory that I do not have permisions for, unfortunately at this point an UnathorisedAccessException is thrown which is perfecty understandable. What I would like to do is retrieve a list of directories that I do have permission for and ignore any that I don't. Any ideas? Many thanks Paul ps, what event is it thrown for the enter key on a text box??
Paul
Hi, the only way that works for me is by using SearchOption.TopDirectoryOnly and performing the recursion myself, with a try-catch inside the foreach that iterates over the subdirectories at the current nesting level. I see no real use for SearchOption.AllDirectories because of the possible exceptions it does not handle well. :)
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips: - before you ask a question here, search CodeProject, then Google; - the quality and detail of your question reflects on the effectiveness of the help you are likely to get; - use PRE tags to preserve formatting when showing multi-line code snippets.
-
Evening guys, Hopefully a quick question. I am trying to iterate all sub directories within a folder using the DirectoryInfo.GetDirectories() This isall fine until the search hits a directory that I do not have permisions for, unfortunately at this point an UnathorisedAccessException is thrown which is perfecty understandable. What I would like to do is retrieve a list of directories that I do have permission for and ignore any that I don't. Any ideas? Many thanks Paul ps, what event is it thrown for the enter key on a text box??
Paul
-
Hi, the only way that works for me is by using SearchOption.TopDirectoryOnly and performing the recursion myself, with a try-catch inside the foreach that iterates over the subdirectories at the current nesting level. I see no real use for SearchOption.AllDirectories because of the possible exceptions it does not handle well. :)
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips: - before you ask a question here, search CodeProject, then Google; - the quality and detail of your question reflects on the effectiveness of the help you are likely to get; - use PRE tags to preserve formatting when showing multi-line code snippets.
-
pprice wrote:
what event is it thrown for the enter key on a text box??
handle one of the text boxes Key Events and check the event args to see if the KeyCode is
Keys.Enter