| Previous | Next |
| ERROR_REM_NOT_LIST |
ERROR_SHARING_VIOLATION
ERROR_SHARING_VIOLATION means that the requested access and sharing mode conflict with an already open handle to the same file or device. It is not, by itself, proof that the caller lacks permission.
Why it happens
Every CreateFile call declares both the access it needs and which access it allows later callers to request. A new open fails when its requested access conflicts with the sharing flags of an existing handle. The sharing policy remains in force until that existing handle is closed.
Common cases
- An application opens a file with
dwShareModeequal to zero and later attempts to open it again. - A reader or writer omitted
FILE_SHARE_READorFILE_SHARE_WRITEeven though concurrent access is intended. - A missing
FILE_SHARE_DELETEprevents another process from renaming or deleting the file. - A writable file mapping or another process retains an incompatible handle longer than expected.
How to diagnose it
Check the desired access and sharing mode of handles opened by the application first. If another process owns the conflicting handle, identify why it keeps the file open. Retrying can be appropriate for a short-lived lock, but a retry loop cannot resolve an intentionally incompatible sharing policy.
See Microsoft documentation for CreateFile.
Looking for a different code? Search another status or error code.