Question Status

Freya Tan asked a question on 10 Apr 2013 7:40 PM


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. 

Any ideas?


Bilal Issa responded on 11 Apr 2013 12:45 AM


can you please write the error you are getting?



Freya Tan responded on 11 Apr 2013 1:43 AM

I don't get any error. The batch job succeeds. But the problem, it never execute the file in the directory.

Dominic Lee responded on 11 Apr 2013 1:51 AM

Check the network folder access right, Make sure AOS service account can access the network folder.

Then try again with the network folder setup.

kind regards,

Dominic Lee

My blog | PBC

This forum post is my own opinion and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs.

Bilal Issa responded on 11 Apr 2013 1:57 AM


can you please let me know the code you are using?  are you using WinAPISerevr, or something else?



Freya Tan responded on 11 Apr 2013 2:06 AM

I'm using System.IO not WinAPIServer.

Bilal Issa responded on 11 Apr 2013 2:18 AM

so are using the following code?

      filepermission = new FileIOPermission(fileName, 'R');

       interopPermission = new InteropPermission(InteropKind::ClrInterop);

       permissionSet = new Set(Types::Class);






Freya Tan responded on 11 Apr 2013 2:53 PM

I'm getting the file list from the directory first. My method looks like:

// loop all files that fit the required format

   InteropPermission   interopPerm;

   System.Array        files;

   int                 i;

   container           fileList;


   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)));


   return fileList;

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");


   return ret;


Bilal Issa responded on 14 Apr 2013 4:56 AM

please try to use the follwoing code to get the files list.

   System.IO.DirectoryInfo     directory;

   System.IO.FileInfo[]        files;

   System.IO.FileInfo          file;

   InteropPermission           permission;

   str         fileName;

   counter     filesCount;

   counter     loop;

   container   mathchingFiles;


   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 ;



   return mathchingFiles;