Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

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


View products that this article applies to.

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.

↑ Back to the top


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

↑ Back to the top


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

↑ Back to the top


Status

This behavior is by design.

↑ Back to the top


Keywords: KB814110, kbprb, kberrmsg

↑ Back to the top

Article Info
Article ID : 814110
Revision : 5
Created on : 1/10/2007
Published on : 1/10/2007
Exists online : False
Views : 270