How do I determine the HResult for a System.IO.IOException?
For .Net Framework 4.5 and above, you can use the Exception.HResult property: int hr = ex.HResult; For older versions, you can use Marshal.GetHRForException to get back the HResult, but this has significant side-effects and is not recommended: int hr = Marshal.GetHRForException(ex);