Would anyone know if when you catch an UnauthorizedAccessException in C# its possible to access the path that threw it? I dont want the error message just the path that caused the problem. The try catch block I have could catch on a number of different ones but I need to report it it and continue on to the next directory/file without adding the entire exception message.
Would anyone know if when you catch an UnauthorizedAccessException in C# its possible to
Share
Maybe make your error handling more granular so you are only catching a single attempt when it blows up? You could do this (without repeating yourself) by refactoring the offending code out to a utility method – i.e.
Where
TryCopyFilecatches the exception and logs the (single) path that was passed as an argument.