"Cannot Open File" Error Message When You Try to Open a File by Using ADO in a BizTalk Preprocessor (814110)



The information in this article applies to:

  • Microsoft BizTalk Server 2002
  • Microsoft BizTalk Server 2000

SYMPTOMS

When you call the ADO Stream LoadFromFile method from a custom Microsoft BizTalk preprocessor to open the file that is provided in the vDataIn variable, you receive a "cannot open file" error message that states that the file is in use by another process.

CAUSE

This problem occurs because the ADO Stream LoadFromFile method does not use the correct attributes to open the file.

When the BizTalk File Receive function opens the file, it uses the following attributes:
  • FILE_SHARE_READ|FILE_SHARE_DELETE
  • GENERIC_WRITE
When the ADO Stream LoadFromFile method tries to open the file, it uses the following attributes:
  • FILE_SHARE_READ
  • GENERIC_READ
The ADO Stream LoadFromFile method cannot open a file that has been opened previously by using the attributes that BizTalk used to open the file. The file must be opened by using the following attributes:
  • GENERIC_READ
  • FILE_SHARE_READ|FILE_SHARE_WRITE

WORKAROUND

To work around this problem, do one of the following:
  • Copy the contents of the file to another location, and then load the file in the ADO Stream.

    -or-
  • Use another API to gain direct access to the file by using the following attributes:
    • GENERIC_READ
    • FILE_SHARE_READ|FILE_SHARE_WRITE

STATUS

This behavior is by design.

Modification Type:MajorLast Reviewed:6/18/2003
Keywords:kberrmsg kbprb KB814110 kbAudDeveloper