I have, essentially, the same problem as this poster, but in C#: Waiting until a file is available for reading with Win32
More information: we have code that calls <
You can call Marshal.GetHRForException() within the catch clause to get the error code. No need for reflection:
Marshal.GetHRForException()
catch
using System.Runtime.InteropServices; if (Marshal.GetHRForException(e) == ERROR_SHARING_VIOLATION) ....