Getting the (hex) error code from an IOException, or regular Exception!
Is this possible? i know it HAS a error code, (HResult) but the get accessor is private.
I would do some sort of ComException thing, but im not sure about the pros/cons of doing this, and if its even possible/the开发者_C百科 same.
Here it is suggested to call Marshall.GetHRForException.
Derive a specified class from Exception or IOException and expose the HRESULT value through an internal property.
class MyException:Exception
{
internal GetHRResult()
{
return base.get_HResult();
}
.....
}
精彩评论