| Previous | Next |
| STATUS_INVALID_PORT_HANDLE | STATUS_QUOTA_EXCEEDED |
STATUS_SHARING_VIOLATION
STATUS_SHARING_VIOLATION is an open-time conflict, not a generic permissions failure. Windows evaluates both the access requested by the new caller and the sharing flags granted by handles that are already open for the same file, directory, device, or named pipe. The open is rejected when either side does not permit the other side's requested access.
Why an apparently readable file can still fail to open
A handle can allow reading yet deny a second caller's write, rename, or delete request. For example, an application that opens a file without FILE_SHARE_DELETE can prevent another process from deleting or renaming it until that handle is closed. Likewise, a handle opened with a zero sharing mode is exclusive: later opens are incompatible regardless of ordinary file permissions.
How to diagnose the conflict
- Record the requested
dwDesiredAccessanddwShareModefor the failingCreateFileor native create request. - Check whether the operation actually needs read, write, or delete access. Rename and delete workflows commonly require delete sharing.
- Identify the process or service retaining the existing handle and whether it deliberately uses exclusive access.
- Use a bounded retry only when the holder is expected to close soon. A retry loop cannot fix incompatible sharing policy.
This status is different from STATUS_FILE_LOCK_CONFLICT: a sharing violation prevents a compatible handle from being opened, while a byte-range lock can block I/O after a handle has already been opened.
See CreateFile, Closing and Deleting Files, and the NTSTATUS reference.
Looking for a different code? Search another status or error code.