开发者

Getting the error code from an IOException

开发者 https://www.devze.com 2023-01-21 02:30 出处:网络
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.

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

精彩评论

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