Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. DirectoryInfo.GetDirectories()

DirectoryInfo.GetDirectories()

Scheduled Pinned Locked Moved C#
question
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    PaulPrice
    wrote on last edited by
    #1

    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

    L J 2 Replies Last reply
    0
    • P PaulPrice

      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

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      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.


      P 1 Reply Last reply
      0
      • P PaulPrice

        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

        J Offline
        J Offline
        Jimmanuel
        wrote on last edited by
        #3

        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

        P 1 Reply Last reply
        0
        • L Luc Pattyn

          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.


          P Offline
          P Offline
          PaulPrice
          wrote on last edited by
          #4

          Sounds good, many thanks

          Paul

          1 Reply Last reply
          0
          • J Jimmanuel

            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

            P Offline
            P Offline
            PaulPrice
            wrote on last edited by
            #5

            Kinda hoped there would be a more specific event that I did not know about, ho well, many thanks anyway

            Paul

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups