It depends on the type of exception thrown. The base Exception class does not expose an exception code. There is an HResult, but it is not a public member.
A exception type of COMException has an ErrorCode, which contains the standard COM errors. You should check the type of error being thrown and see if it has a an ErrorCode or equivalent field. Exceptions also contain an InnerException property, which if set may provide the additional detail needed.
try
{
// something
}
catch (COMException ce)
{
if (ce.ErrorCode == 0x800A03EC)
{
// try something else
}
}