I'm running FXCop to clean up my code, and FXCop complains about how Im catching the exception. "You should not catch Exception or SystemException. Catching generic exception types can hide run-time problems from the library user, and can complicate debugging. You should catch only those exceptions that you can handle gracefully."
Here is a sample of my code, does anyone know how this can be improved, (so that FxCop does not complain?)
Thanks :)
catch(Exception e) { if(e is IOException) { Console.WriteLine("{0} System IO Exception", e); } if (e is DirectoryNotFoundException) { Console.WriteLine("{0} Directory not found", e); } if (e is ArgumentException) { Console.WriteLine("{0} Directory is invalid", e); } if(e is PathTooLongException) { Console.WriteLine("{0} Directory path is too long", e); } if (e is UnauthorizedAccessException) { Console.WriteLine("{0} Unauthorised to delete directory", e); } }