After running my batch job on server ,files has to be moved from one folder to another folder in ax2012.Do we have a sample code for this requirement.
After running my batch job on server ,files has to be moved from one folder to another folder in ax2012.Do we have a sample code for this requirement.
I have used System.IO as Martin recommends. Make sure that the AOS Service account has permissions to the from and to locations for you file(s). When running in batch mode the code will use the AOS Service account for file system access.
If it turns out that the batch needs to run on a client session, you can refer to below article to enable it
docs.microsoft.com/.../walkthrough-extending-runbasebatch-class-to-create-and-run-a-batch
Please check the WinAPI and WinAPIServer classes. There are methods to work with files like fileExists, copyFile, deleteFile. You can check DocuRef.delete() method to see how the system handles the file deletion on the client and how it is handled on the server.
I would use System.IO.File::Move(). For example:
InteropPermission permission = new InteropPermission(InteropKind::ClrInterop); permission.assert(); try { System.IO.File::Move(@'\\locationSharedByAllAos\from\file.txt', @'\\locationSharedByAllAos\to\file.txt'); } catch (Exception::CLRError) { throw error(AifUtil::getClrErrorMessage()); }
André Arnaud de Cal...
292,516
Super User 2025 Season 1
Martin Dráb
231,321
Most Valuable Professional
nmaenpaa
101,156