How to get correct network folder path in batch?

Hi All,

How to get correct network folder path when code runs in batch jobs?

I have a class which runs in batch job to read text files from network folder & imports data in AX 2012 & move file to another folder.

During moving file to destination folder, system is not taking correct path & error log comes as "System.UnauthorizedAccessException: Access to the path is denied."

like: 

Source path : \\JCBiztalk\Testing_From\ABC.txt

Destination path : \\JCBiztalk\Testing_To\ABC.txt

when batch job runs & tries to move file, FilePath variable takes path as : \\\\JCBiztalk\\Testing_from\\ABC.txt. (with extra slashes).

I need the same path as Source path & destination path when moving file using System.IO.File::Move(_fromLocation,_toLocation).

Also,

I am able to get correct path in directoryInfo using System.IO.DirectoryInfo(_fromLocation), but unable to convert directoryInfo to string to get full path to move file !!

Kindly help me in this.

Regards,

Arun Khanna

Parents
  • I don't think that this is the cause of your problem. The extra backslashes are likely just a visualization escaping each backslash (a special character) with another backslash (as the escape character).

    Also, the error doesn't say that the folder can't be found, it says that the current user (= AOS service account) doesn't have permissions to work with it. Your test with DirectoryInfo is yet another proof that the path is fine.

    Therefore I suggest you look at permissions instead of the path.

Reply Children
Related
Recommended