Solved

Executing API 'CreateFile' failed with error number 32.

  • 18 February 2020
  • 2 replies
  • 1231 views

Userlevel 5
Badge +16
  • Thinkwise Local Partner Brasil
  • 384 replies

Does anybody know a good way to catch and prevent the error, when a file for some reason is locked for reading and processing?

Executing API 'CreateFile' failed with error number 32.

Error code 32 is ERROR_SHARING_VIOLATION . So the mailer cannot read the attachment file because something else is reading it.

Besides the fact that you cannot really reproduce it until it happens, I cannot really find a way to catch this error upfront. I am using the file_exists function to check upfront if all documents exists, and even though all attachments can be found, at the time of sending the mail at occasions you get this error. 

The only solution I can think of now is to set the AccountRetryAttempts to 2 times to tackle this problem. But it's not the fanciest solution, anyone has experiences with this?

icon

Best answer by Erik Brink 26 February 2020, 09:38

View original

2 replies

Userlevel 5
Badge +5

Hi Freddy,

Maybe think of a file location where users could only get a copy of the original file?

For example, from the GUI point of view there is a difference between the usage of controls of type File/Image Upload or File/Image Link. The "Link” control will open the original file directly. The "Upload” control will download a copy of it.

 

Do you know who else is accessing and locking the file at that moment? 

Regards, Erik

Userlevel 5
Badge +16

Do you know who else is accessing and locking the file at that moment? 

 

My educated guess was that the reporting service might not be entirely finished writing the file to the disk, but it's not very feasible, because the file_exists function that runs before doesn't give a similar error, which I would expect it to do. For now I just added a 1 second delay before sending the mail, and so far so good. 

Reply