I'm running the code below and getting exception below. Am I forced to put this function in try catch or is there other way to get all directories recursively? I could write my own recursive function to get files and directory. But I wonder if there is a better way.
// get all files in folder and sub-folders
var d = Directory.GetFiles(@"C:\", "*", SearchOption.AllDirectories);
// get all sub-directories
var dirs = Directory.GetDirectories(@"C:\", "*", SearchOption.AllDirectories);
"Access to the path 'C:\Documents and Settings\' is denied."