CIL server code AX 2012 file access problem when moving file

Hello,

I get a problem when I run my code in Batch.

The code is run Server side in IL code. I try to move a file which I closed before and get following .NET error :

“The process cannot access the file because it is being used by another process.”

I don’t understand why I get this, the code runs fine on client side. The file is first opened with a standard AX Asciiio object and at last I call the .close() method. After the close method I call the method below

file.close();

System.IO.File::Move(_fileName, _newFileName);

What can be the problem here :s. I close the file but still I get this error. I even putted a sleep method between the close method and the move call. This code runs fine when not run in Batch (IL code).

Thx in advance.

After file.close(), set file = null, and then call the .Net methods.

setting file = null will unlock the file. This is the method of using the file object from previous versions.

hmm actually file = null is standing after the .close() I forgot to put it here. Still not working :frowning:

Hi Nicholas,

Did you find any solution for this issue? I’m having the same issue right now.

Kind regards

Thomas

use dispose() after the close()