try
{
//代码
}
catch(Exception e)
{
var w32ex = e as Win32Exception;
if (w32ex == null)
{
w32ex = e.InnerException as Win32Exception;
}
if (w32ex != null)
{
//根据code来判别错误
int code = w32ex.ErrorCode;
}
}
本文介绍了一种使用try-catch结构进行异常处理的方法,并详细展示了如何从捕获到的异常中获取Win32异常的具体信息,以便进一步判断错误类型。
1250

被折叠的 条评论
为什么被折叠?



