Error Writing stream file

Hello,

when I run this method from a runbasebatch class I get an exception error in the calling new() method, if I run from Job I get not errors.

Any idea?

from runbasebatch: **LSP_FileManager::writeFileStream(**fileName, content);

server static void writeFileStream(str _fileName, str _content)
{
System.IO.StreamWriter sw;
InteropPermission perm = new InteropPermission(InteropKind::ClrInterop);
;

perm.assert();

sw = new System.IO.StreamWriter(_fileName, false);

sw.Write(_content);
sw.Flush();
sw.Close();
sw.Dispose();

CodeAccessPermission::revertAssert();
}

where _filename is '\se-srv3\mydir\filetest.txt’

and the job:

server static void job15_writefilestream()
{
System.IO.StreamWriter sw;
InteropPermission perm = new InteropPermission(InteropKind::ClrInterop);
str _fileName = @’\Se-srv3*mydir\filetest.txt*’;
str _content =“A”;
;
perm.assert();

sw = new System.IO.StreamWriter(_fileName, false);

sw.Write(_content);
sw.Flush();
sw.Close();
sw.Dispose();

CodeAccessPermission::revertAssert();
}

Object ‘CLRObject’ could not be created

Found by myself.

The user related to the AOS Service should be authorized to these paths