I have a batch job that will import a file. The import file is saved in a different server (not where the AOS resides). The batch job runs if I just use a directory where the AOS is installed. Also, if I run the class manually (not as batch job) and I use a network directory, I can import the file successfully.
can you please write the error you are getting?
I don't get any error. The batch job succeeds. But the problem, it never execute the file in the directory.
Check the network folder access right, Make sure AOS service account can access the network folder.
Then try again with the network folder setup.
can you please let me know the code you are using? are you using WinAPISerevr, or something else?
I'm using System.IO not WinAPIServer.
so are using the following code?
filepermission = new FileIOPermission(fileName, 'R');
interopPermission = new InteropPermission(InteropKind::ClrInterop);
permissionSet = new Set(Types::Class);
I'm getting the file list from the directory first. My method looks like:
// loop all files that fit the required format
interopPerm = new InteropPermission(InteropKind::ClrInterop);
files = System.IO.Directory::GetFiles(@_sourceDirectory, #FileExtension);
for( i=0; i<ClrInterop::getAnyTypeForObject(files.get_Length()); i++ )
fileList = conins(fileList, conlen(fileList)+1, ClrInterop::getAnyTypeForObject(files.GetValue(i)));
Then I loop on the container to process each file. I open the file and assign it to a CommaIo. My code looks like:
boolean openFile(Filename _fileName)
boolean ret = true;
csvFile = null;
csvFile = new CommaIo(_fileName, #io_read);
//Error when opening file
ret = checkFailed("@SYS69639");
please try to use the follwoing code to get the files list.
permission = new InteropPermission(InteropKind::ClrInterop);
directory = new System.IO.DirectoryInfo(_folderPath);
files = directory.GetFiles(_filePattern);
filesCount = files.get_Length();
for (loop = 0; loop < filesCount; loop++)
file = files.GetValue(loop);
fileName = file.get_FullName();
mathchingFiles += fileName ;
Hi Freya Tan
I'm trying to export my data to CSV via batch processing and facing errors, my code work in client side but not on Batch, Have you got any solution?
When code is running in batch, they are most likely running on server. Make sure the AOS service account has proper folder rights and the path you specified is in UNC network path.
If your filepath begins with an ip address and then the folder path, (considering the batch server) and the target machine are connected, this should be a fairly straight-forward task.
Hi Dominic Lee,
My code at below line returning the Null value when running in the batch process, where as when I run it on client working perfectly..
file = new CommaIo(filename,#io_write);
Will CommaIo class run at Server side?
CommaIO will run server side, but WinAPI class calls will not (try WinAPIServer or better to use System.IO namespace from .Net). The problem could also be with your filename, since a regular drive letter and folder would be local to your server. Try a UNC network share, where the AX AOS account has Full access permissions both on the folder and the file share.
If you are using SysOperation framework then it's server side. If you are using Runbase batch framework then it depends.
Nonetheless, try UNC path first, like Crispin and Vilmos also suggesting. :)