开发者

Getting the error code from an IOException

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();
   } 
   .....
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜