title: C# Handle System.UnauthorizedAccessException in LINQ
body: <p>I am using below LINQ query to get the directory list. I am getting an error (System.UnauthorizedAccessException was unhandled by user code). How to load only the directories to which I have access to.</p>
  
  <pre><code>var files = from f in System.IO.Directory.GetDirectories(@"\\testnetwork\abc$",
                                     "*.*",
                                     SearchOption.AllDirectories)
              select System.IO.Path.GetDirectoryName(f);
  </code></pre>
  
  <p>Error:</p>
  
  <p>Access to the path '\testnetwork\abc$\DemoFolder\' is denied.</p>