Skip to main content
Jul 18, 2022 7:54 AM UTC

BR throws an error. The process cannot access the file because it is being used by another process.

I am getting an error while trying to access the file from the BR .

The process cannot access the file '\\XXXXXX.file.core.windows.net\onestreamshareprd1\FileShare\Applications\XXXXXXX\Groups\Everyone\XXXXXX\File_XXXXX.zip' because it is being used by another process.

4 replies

ChristianW
Employee - Advisor
Employee - Advisor
Jul 18, 2022 1:36 PM UTC

If you access a file from a business rule, you first need open the file, than you do your activity, and then you close it. This is VB.net standard. If you open the file, but not close it, an error message like yours appears.

A common reason for open files is an error during the runtime, so that you opened the file but never succeed closing it. To avoid such a situation, you can use the try error handling to close the file even after running in a bug.

Contributor
Nov 29, 2022 3:04 PM UTC

I am getting the same error when trying to write to a file ... I think it's due to multithreading

Dim oFile As StreamWriter =  New StreamWriter(BRAPi.Utilities.GetFileShareFolder(si, FileShareFolderTypes.ApplicationIncoming, Nothing).Replace("\Incoming","\Groups\Everyone\test1.txt"),True)

oFile.WriteLine( api.Pov.Time.Name & " | " & api.Pov.Entity.Name & " | " & dataBuffSource.DataBufferCells.Count & " | " & elapsedTime )

oFile.Close
ChristianW
Employee - Advisor
Employee - Advisor
Dec 25, 2022 1:09 PM UTC

Probably. There are asynchronous versions of Write and WriteLine: WriteAsync and WriteLineAsync. But didn‘t tried it yet, so I don‘t know details.

Contributor
Jan 3, 2023 2:33 PM UTC

Thank You Chrsitian for the reply! I will look into those two methods for my business rule