Question: How to **bypass/ignore** "Access to the path is denied"/UnauthorizedAccess exception 

and ***continue*** to collecting filenames in this method;

```
public static string[] GetFilesAndFoldersCMethod(string path)
{
   string[] filenames = Directory.GetFiles(path, "*.*", SearchOption.AllDirectories).Select(Path.GetFullPath).ToArray();
   return filenames;
}

```

//Calling... ...

```
foreach (var s in GetFilesAndFoldersCMethod(@"C:/"))
{
    Console.WriteLine(s);
}

```

My application stops on the firstline of GetFilesAndFoldersCMethod and an exception says;
"Access to the path 'C:\@Logs\' is denied.". Please help me...

Thanks,

Answer: 
Have a look at this article in the c# programming guide:

[How to: Iterate Through a Directory Tree (C# Programming Guide)](http://msdn.microsoft.com/en-us/library/bb513869.aspx)
Based on the MS page and the various attempts on here on stackoverflow, I have a solution that seems to work, and avoids all the GetFiles()/GetDirectories() exceptions.

cf <https://stackoverflow.com/a/10728792/89584>

(original question might be considered a duplicate of this, or vice-versa).