Skip to content

Instantly share code, notes, and snippets.

@FrankDeGroot
Created September 24, 2013 12:11
Show Gist options
  • Save FrankDeGroot/6683823 to your computer and use it in GitHub Desktop.
Save FrankDeGroot/6683823 to your computer and use it in GitHub Desktop.
Check if IOException is caused by a file lock.
private static bool IsFileLocked(IOException exception)
{
int errorCode = Marshal.GetHRForException(exception) & ((1 << 16) - 1);
return errorCode == 32 || errorCode == 33;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment