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.
var files = from f in System.IO.Directory.GetDirectories(@"\\testnetwork\abc$",
"*.*",
SearchOption.AllDirectories)
select System.IO.Path.GetDirectoryName(f);
Error:
Access to the path ‘\testnetwork\abc$\DemoFolder\’ is denied.
Catch the UnauthorizedAccessException using Catch. .
ExceptionExtensions: