Skip to main content
Veteran
July 18, 2022

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

  • July 18, 2022
  • 3 replies
  • 0 views

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.

3 replies

OneStream Employee
July 18, 2022

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
November 29, 2022

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
OneStream Employee
December 25, 2022

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
January 3, 2023

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