PRB: Opening a File Twice with Compatible Sharing Modes Fails

ID: Q195606


The information in this article applies to:
  • Microsoft Win32 Application Programming Interface (API), used with:
    • Microsoft Windows NT versions 3.5, 3.51, 4.0
    • Microsoft Windows 95
    • Microsoft Windows 98
    • Microsoft Windows 2000


SYMPTOMS

When one or more processes try to open the same file more than once with compatible access and sharing modes at nearly the same time, sometimes the second attempt to open the file fails with error 32 (ERROR_SHARING_VIOLATION).


CAUSE

This behavior can be caused by applications that are running that intercept calls to open a file to do their own processing first. These applications can open the file in an incompatible mode, causing subsequent attempts to open the file to fail with a sharing violation. A typical example of this type of application is a virus scanner.


RESOLUTION

To open the file without the error, do one of the following:

  • Try to open the file again. This attempt to open the file should succeed after the application is finished processing.


  • Disable the option in the application that checks files when they are opened.



MORE INFORMATION

If an application, such as a virus scanner, is set up to check files when they are opened, the application might hold the file open in an incompatible mode while processing the file, causing other applications to receive sharing violations when attempting to open the file.

Additional query words:

Keywords : kbAPI kbFileIO kbKernBase kbNTOS350 kbNTOS351 kbNTOS400 kbWinOS2000 kbWinOS95 kbWinOS98 kbDSupport kbGrpKernBase
Version : winnt:3.5,3.51,4.0
Platform : winnt
Issue type : kbprb


Last Reviewed: January 10, 2000
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.