Import file on network in Batch job

This question is not answered


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?


All Replies
  • Hi,

    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.

    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.

  • Hi,

    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

       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;


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